Add a cache system on the referential info
+ Add an identity service
This commit is contained in:
@@ -8,11 +8,12 @@ using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DataContract;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
public class DropZoneController : Base
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public DropZoneController(IDropZoneService dropZoneService,
|
||||
IMapper mapper)
|
||||
{
|
||||
@@ -20,12 +21,32 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// PUT: api/DropZone/AddToFavorite/5
|
||||
[HttpPut("AddToFavorite/{id}")]
|
||||
[EnableCors]
|
||||
public bool AddToFavorite(int id)
|
||||
{
|
||||
return _dropZoneService.AddToFavorite(id);
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_dropZoneService.DeleteDzById(id);
|
||||
}
|
||||
|
||||
// GET: api/DropZone
|
||||
[HttpGet]
|
||||
[EnableCors]
|
||||
public IEnumerable<DropZoneResp> Get()
|
||||
{
|
||||
var result = _dropZoneService.GetAllDzs(ConnectedUser);
|
||||
var result = _dropZoneService.GetAllDzs();
|
||||
|
||||
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||
}
|
||||
@@ -56,31 +77,21 @@ namespace skydiveLogs_api.Controllers
|
||||
return _dropZoneService.UpdateDz(id, _mapper.Map<DropZone>(value));
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_dropZoneService.DeleteDzById(id);
|
||||
}
|
||||
|
||||
// PUT: api/DropZone/AddToFavorite/5
|
||||
[HttpPut("AddToFavorite/{id}")]
|
||||
[EnableCors]
|
||||
public bool AddToFavorite(int id)
|
||||
{
|
||||
return _dropZoneService.AddToFavorite(id, ConnectedUser);
|
||||
}
|
||||
|
||||
// PUT: api/DropZone/RemoveToFavorite/15
|
||||
[HttpPut("RemoveToFavorite/{id}")]
|
||||
[EnableCors]
|
||||
public bool RemoveToFavorite(int id)
|
||||
{
|
||||
return _dropZoneService.RemoveToFavorite(id, ConnectedUser);
|
||||
return _dropZoneService.RemoveToFavorite(id);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IDropZoneService _dropZoneService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,12 @@ using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DataContract;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
public class GearController : Base
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public GearController(IGearService gearService,
|
||||
IMapper mapper)
|
||||
{
|
||||
@@ -20,12 +21,25 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// DELETE: api/ApiWithActions/5
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_gearService.DeleteGearById(id);
|
||||
}
|
||||
|
||||
// GET: api/Gear
|
||||
[HttpGet]
|
||||
[EnableCors]
|
||||
public IEnumerable<GearResp> Get()
|
||||
{
|
||||
var result = _gearService.GetAllGears(ConnectedUser);
|
||||
//var result = _gearService.GetAllGears(ConnectedUser);
|
||||
var result = _gearService.GetAllGears();
|
||||
return _mapper.Map<IEnumerable<GearResp>>(result);
|
||||
}
|
||||
|
||||
@@ -43,7 +57,7 @@ namespace skydiveLogs_api.Controllers
|
||||
[EnableCors]
|
||||
public void Post([FromBody] GearReq value)
|
||||
{
|
||||
_gearService.AddNewGear(_mapper.Map<Gear>(value), ConnectedUser);
|
||||
_gearService.AddNewGear(_mapper.Map<Gear>(value));
|
||||
}
|
||||
|
||||
// PUT: api/Gear/5
|
||||
@@ -54,16 +68,14 @@ namespace skydiveLogs_api.Controllers
|
||||
_gearService.UpdateGear(id, _mapper.Map<Gear>(value));
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions/5
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_gearService.DeleteGearById(id);
|
||||
}
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IGearService _gearService;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,12 @@ using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DataContract;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
public class ImageController : Base
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ImageController(IUserImageService imageService,
|
||||
IMapper mapper)
|
||||
{
|
||||
@@ -20,12 +21,24 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// DELETE: api/Image/5
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_imageService.DeleteImageById(id);
|
||||
}
|
||||
|
||||
// GET: api/Image
|
||||
[HttpGet]
|
||||
[EnableCors]
|
||||
public IEnumerable<ImageResp> Get()
|
||||
{
|
||||
var result = _imageService.GetAllImages(ConnectedUser);
|
||||
var result = _imageService.GetAllImages();
|
||||
return _mapper.Map<IEnumerable<ImageResp>>(result);
|
||||
}
|
||||
|
||||
@@ -43,7 +56,7 @@ namespace skydiveLogs_api.Controllers
|
||||
[EnableCors]
|
||||
public void Post([FromBody] ImageReq value)
|
||||
{
|
||||
_imageService.AddNewImage(_mapper.Map<UserImage>(value), ConnectedUser);
|
||||
_imageService.AddNewImage(_mapper.Map<UserImage>(value));
|
||||
}
|
||||
|
||||
// PUT: api/Image/5
|
||||
@@ -54,15 +67,13 @@ namespace skydiveLogs_api.Controllers
|
||||
_imageService.UpdateImage(id, _mapper.Map<UserImage>(value));
|
||||
}
|
||||
|
||||
// DELETE: api/Image/5
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_imageService.DeleteImageById(id);
|
||||
}
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IUserImageService _imageService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
|
||||
using AutoMapper;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using skydiveLogs_api.DataContract;
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DataContract;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
public class JumpController : Base
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public JumpController(IJumpService jumpService,
|
||||
IMapper mapper)
|
||||
{
|
||||
@@ -20,12 +19,24 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// DELETE: api/Jump/5
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_jumpService.DeleteJumpById(id);
|
||||
}
|
||||
|
||||
// GET: api/Jump
|
||||
[HttpGet]
|
||||
[EnableCors]
|
||||
public IEnumerable<JumpResp> Get()
|
||||
{
|
||||
var result = _jumpService.GetAllJumps(ConnectedUser);
|
||||
var result = _jumpService.GetAllJumps();
|
||||
|
||||
return _mapper.Map<IEnumerable<JumpResp>>(result);
|
||||
}
|
||||
@@ -48,8 +59,7 @@ namespace skydiveLogs_api.Controllers
|
||||
value.DropZoneId,
|
||||
value.JumpTypeId,
|
||||
value.GearId,
|
||||
_mapper.Map<Jump>(value),
|
||||
ConnectedUser);
|
||||
_mapper.Map<Jump>(value));
|
||||
}
|
||||
|
||||
// PUT: api/Jump/5
|
||||
@@ -60,15 +70,13 @@ namespace skydiveLogs_api.Controllers
|
||||
_jumpService.UpdateJump(id, _mapper.Map<Jump>(value));
|
||||
}
|
||||
|
||||
// DELETE: api/Jump/5
|
||||
[HttpDelete("{id}")]
|
||||
[EnableCors]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_jumpService.DeleteJumpById(id);
|
||||
}
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IJumpService _jumpService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
|
||||
using AutoMapper;
|
||||
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using skydiveLogs_api.DataContract;
|
||||
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
public class StatsController : Base
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsController(IStatsService statsService,
|
||||
IMapper mapper)
|
||||
{
|
||||
@@ -19,38 +18,24 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpGet("Simple")]
|
||||
[EnableCors]
|
||||
public SimpleSummaryResp Simple()
|
||||
{
|
||||
var result = _statsService.GetSimpleSummary(ConnectedUser);
|
||||
#endregion Public Constructors
|
||||
|
||||
return _mapper.Map<SimpleSummaryResp>(result);
|
||||
#region Public Methods
|
||||
|
||||
[HttpGet("ByAircraft")]
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByAircraft()
|
||||
{
|
||||
var result = _statsService.GetStatsByAircraft();
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ByDz")]
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByDz()
|
||||
{
|
||||
var result = _statsService.GetStatsByDz(ConnectedUser);
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ByAircraft")]
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByAircraft()
|
||||
{
|
||||
var result = _statsService.GetStatsByAircraft(ConnectedUser);
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ByJumpType")]
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByJumpType()
|
||||
{
|
||||
var result = _statsService.GetStatsByJumpType(ConnectedUser);
|
||||
var result = _statsService.GetStatsByDz();
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
@@ -59,7 +44,16 @@ namespace skydiveLogs_api.Controllers
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByGear()
|
||||
{
|
||||
var result = _statsService.GetStatsByGear(ConnectedUser);
|
||||
var result = _statsService.GetStatsByGear();
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ByJumpType")]
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByJumpType()
|
||||
{
|
||||
var result = _statsService.GetStatsByJumpType();
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
@@ -68,31 +62,17 @@ namespace skydiveLogs_api.Controllers
|
||||
[EnableCors]
|
||||
public IEnumerable<StatisticResp> ByYear()
|
||||
{
|
||||
var result = _statsService.GetStatsByYear(ConnectedUser);
|
||||
var result = _statsService.GetStatsByYear();
|
||||
|
||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ForLastYear")]
|
||||
[EnableCors]
|
||||
public StatisticForLastYearResp ForLastYear()
|
||||
{
|
||||
var resultByDz = _statsService.GetStatsForLastYearByDz(ConnectedUser);
|
||||
var resultByJumpType = _statsService.GetStatsForLastYearByJumpType(ConnectedUser);
|
||||
|
||||
var result = new StatisticForLastYearResp();
|
||||
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
||||
result.ByJumpType = _mapper.Map<IEnumerable<StatisticResp>>(resultByJumpType);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet("ForLastMonth")]
|
||||
[EnableCors]
|
||||
public StatisticForLastMonthResp ForLastMonth()
|
||||
{
|
||||
var resultByDz = _statsService.GetStatsForLastMonthByDz(ConnectedUser);
|
||||
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType(ConnectedUser);
|
||||
var resultByDz = _statsService.GetStatsForLastMonthByDz();
|
||||
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType();
|
||||
|
||||
var result = new StatisticForLastMonthResp();
|
||||
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
||||
@@ -101,10 +81,36 @@ namespace skydiveLogs_api.Controllers
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet("ForLastYear")]
|
||||
[EnableCors]
|
||||
public StatisticForLastYearResp ForLastYear()
|
||||
{
|
||||
var resultByDz = _statsService.GetStatsForLastYearByDz();
|
||||
var resultByJumpType = _statsService.GetStatsForLastYearByJumpType();
|
||||
|
||||
var result = new StatisticForLastYearResp();
|
||||
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
||||
result.ByJumpType = _mapper.Map<IEnumerable<StatisticResp>>(resultByJumpType);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet("Simple")]
|
||||
[EnableCors]
|
||||
public SimpleSummaryResp Simple()
|
||||
{
|
||||
var result = _statsService.GetSimpleSummary();
|
||||
|
||||
return _mapper.Map<SimpleSummaryResp>(result);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private properties
|
||||
private readonly IStatsService _statsService;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
#endregion
|
||||
private readonly IStatsService _statsService;
|
||||
|
||||
#endregion Private properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,22 +13,48 @@ using skydiveLogs_api.Ioc;
|
||||
using skydiveLogs_api.Settings;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.EnvironmentName == "Development")
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseMvc();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddMvc(options => { options.EnableEndpointRouting = false; })
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
// JWT
|
||||
var jwtSection = Configuration.GetSection("JWT");
|
||||
services.Configure<JwtSettings>(jwtSection);
|
||||
@@ -77,24 +103,9 @@ namespace skydiveLogs_api
|
||||
CheckAndInitDb(services);
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.EnvironmentName == "Development")
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
#endregion Public Methods
|
||||
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseMvc();
|
||||
}
|
||||
#region Private Methods
|
||||
|
||||
private void CheckAndInitDb(IServiceCollection services)
|
||||
{
|
||||
@@ -109,6 +120,12 @@ namespace skydiveLogs_api
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user