Test Connection

Add Todo
Bot use Webservice now
TBD : Rework Event
This commit is contained in:
2019-03-27 00:37:11 +01:00
parent 74327eb381
commit 63db02d798
25 changed files with 379 additions and 178 deletions

View File

@@ -0,0 +1,22 @@
using LaDOSE.Business.Interface;
using LaDOSE.DTO;
using LaDOSE.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace LaDOSE.Api.Controllers
{
[Authorize]
[Route("api/[controller]")]
[Produces("application/json")]
public class TodoController : GenericControllerDTO<ITodoService, Todo, TodoDTO>
{
public TodoController(ITodoService service) : base(service)
{
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using LaDOSE.Business.Interface;
using LaDOSE.DTO;
using LaDOSE.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -50,20 +51,21 @@ namespace LaDOSE.Api.Controllers
{
new Claim(ClaimTypes.Name, user.Id.ToString())
}),
Expires = DateTime.UtcNow.AddDays(7),
Expires = DateTime.UtcNow.AddMinutes(16),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
};
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);
// return basic user info (without password) and token to store client side
return Ok(new
return Ok(new ApplicationUserDTO
{
Id = user.Id,
Username = user.Username,
FirstName = user.FirstName,
LastName = user.LastName,
Token = tokenString
Token = tokenString,
Expire = token.ValidTo
});
}

View File

@@ -96,6 +96,7 @@ namespace LaDOSE.Api
// return unauthorized if user no longer exists
context.Fail("Unauthorized");
}
return Task.CompletedTask;
}
};
@@ -117,9 +118,10 @@ namespace LaDOSE.Api
cfg.CreateMap<WPUser, LaDOSE.DTO.WPUserDTO>();
cfg.CreateMap<WPUser, LaDOSE.DTO.WPUserDTO>();
cfg.CreateMap<WPEvent, LaDOSE.DTO.WPEventDTO>();
cfg.CreateMap<ApplicationUser, LaDOSE.DTO.ApplicationUser>();
cfg.CreateMap<ApplicationUser, LaDOSE.DTO.ApplicationUserDTO>();
cfg.CreateMap<WPBooking, LaDOSE.DTO.WPBookingDTO>().ForMember(e=>e.Meta,opt=>opt.MapFrom(s=>s.Meta.CleanWpMeta()));
cfg.CreateMapTwoWay<Game, LaDOSE.DTO.GameDTO>();
cfg.CreateMapTwoWay<Todo, LaDOSE.DTO.TodoDTO>();
});
}
@@ -133,6 +135,7 @@ namespace LaDOSE.Api
services.AddScoped<IEventService, EventService>();
services.AddScoped<ISeasonService, SeasonService>();
services.AddScoped<IWordPressService, WordPressService>();
services.AddScoped<ITodoService, TodoService>();
}