WebAPI user adapters & controllers, binding + view models
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.AdapterContracts.OperationResponses;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
using YAPContracts.DataModels;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts
|
||||||
|
{
|
||||||
|
public interface IPurchaseAdapter
|
||||||
|
{
|
||||||
|
PurchaseOperationResponse GetList();
|
||||||
|
|
||||||
|
PurchaseOperationResponse GetElement(string id);
|
||||||
|
|
||||||
|
PurchaseOperationResponse GetByUserAndPeriod(string userId, DateTime fromDate, DateTime toDate);
|
||||||
|
|
||||||
|
PurchaseOperationResponse GetByPeriod(DateTime fromDate, DateTime toDate);
|
||||||
|
|
||||||
|
PurchaseOperationResponse InsertPurchase(PurchaseBindingModel purchase);
|
||||||
|
|
||||||
|
PurchaseOperationResponse UpdatePurchase(PurchaseBindingModel purchase);
|
||||||
|
|
||||||
|
PurchaseOperationResponse DeletePurchase(string id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.AdapterContracts.OperationResponses;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts
|
||||||
|
{
|
||||||
|
public interface IStorekeeperAdapter
|
||||||
|
{
|
||||||
|
StorekeeperOperationResponse GetList();
|
||||||
|
|
||||||
|
StorekeeperOperationResponse GetElement(string id);
|
||||||
|
|
||||||
|
StorekeeperOperationResponse Register(StorekeeperBindingModel purchase);
|
||||||
|
|
||||||
|
StorekeeperOperationResponse Update(StorekeeperBindingModel purchase);
|
||||||
|
|
||||||
|
StorekeeperOperationResponse Delete(string id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.AdapterContracts.OperationResponses;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts
|
||||||
|
{
|
||||||
|
public interface IWorkerAdapter
|
||||||
|
{
|
||||||
|
WorkerOperationResponse GetList();
|
||||||
|
|
||||||
|
WorkerOperationResponse GetElement(string id);
|
||||||
|
|
||||||
|
WorkerOperationResponse Register(WorkerBindingModel purchase);
|
||||||
|
|
||||||
|
WorkerOperationResponse Update(WorkerBindingModel purchase);
|
||||||
|
|
||||||
|
WorkerOperationResponse Delete(string id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
internal class CommentOperationResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
internal class ComponentOperationResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
internal class ProductOperationResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
internal class ProductOrderOperationResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
internal class ProductSetOperationResponse
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.Infrastructure;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
public class PurchaseOperationResponse : OperationResponse
|
||||||
|
{
|
||||||
|
public static PurchaseOperationResponse OK(List<PurchaseViewModel> data) => OK<PurchaseOperationResponse, List<PurchaseViewModel>>(data);
|
||||||
|
|
||||||
|
public static PurchaseOperationResponse OK(PurchaseViewModel data) => OK<PurchaseOperationResponse, PurchaseViewModel>(data);
|
||||||
|
|
||||||
|
public static PurchaseOperationResponse NoContent() => NoContent<PurchaseOperationResponse>();
|
||||||
|
|
||||||
|
public static PurchaseOperationResponse BadRequest(string message) => BadRequest<PurchaseOperationResponse>(message);
|
||||||
|
|
||||||
|
public static PurchaseOperationResponse NotFound(string message) => NotFound<PurchaseOperationResponse>(message);
|
||||||
|
|
||||||
|
public static PurchaseOperationResponse InternalServerError(string message) => InternalServerError<PurchaseOperationResponse>(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.Infrastructure;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
public class StorekeeperOperationResponse : OperationResponse
|
||||||
|
{
|
||||||
|
public static StorekeeperOperationResponse OK(List<StorekeeperViewModel> data) => OK<StorekeeperOperationResponse, List<StorekeeperViewModel>>(data);
|
||||||
|
|
||||||
|
public static StorekeeperOperationResponse OK(StorekeeperViewModel data) => OK<StorekeeperOperationResponse, StorekeeperViewModel>(data);
|
||||||
|
|
||||||
|
public static StorekeeperOperationResponse NoContent() => NoContent<StorekeeperOperationResponse>();
|
||||||
|
|
||||||
|
public static StorekeeperOperationResponse BadRequest(string message) => BadRequest<StorekeeperOperationResponse>(message);
|
||||||
|
|
||||||
|
public static StorekeeperOperationResponse NotFound(string message) => NotFound<StorekeeperOperationResponse>(message);
|
||||||
|
|
||||||
|
public static StorekeeperOperationResponse InternalServerError(string message) => InternalServerError<StorekeeperOperationResponse>(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.Infrastructure;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace YAPContracts.AdapterContracts.OperationResponses
|
||||||
|
{
|
||||||
|
public class WorkerOperationResponse : OperationResponse
|
||||||
|
{
|
||||||
|
public static WorkerOperationResponse OK(List<WorkerViewModel> data) => OK<WorkerOperationResponse, List<WorkerViewModel>>(data);
|
||||||
|
|
||||||
|
public static WorkerOperationResponse OK(WorkerViewModel data) => OK<WorkerOperationResponse, WorkerViewModel>(data);
|
||||||
|
|
||||||
|
public static WorkerOperationResponse NoContent() => NoContent<WorkerOperationResponse>();
|
||||||
|
|
||||||
|
public static WorkerOperationResponse BadRequest(string message) => BadRequest<WorkerOperationResponse>(message);
|
||||||
|
|
||||||
|
public static WorkerOperationResponse NotFound(string message) => NotFound<WorkerOperationResponse>(message);
|
||||||
|
|
||||||
|
public static WorkerOperationResponse InternalServerError(string message) => InternalServerError<WorkerOperationResponse>(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,11 @@ namespace YAPContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class PurchaseBindingModel
|
public class PurchaseBindingModel
|
||||||
{
|
{
|
||||||
|
public string? Id { get; set; }
|
||||||
|
|
||||||
public string? UserId { get; set; }
|
public string? UserId { get; set; }
|
||||||
|
|
||||||
|
public double TotalPrice { get; set; }
|
||||||
public DateTime PurchaseDate { get; set; } = DateTime.UtcNow;
|
public DateTime PurchaseDate { get; set; } = DateTime.UtcNow;
|
||||||
public List<ProductInPurchaseBindingModel>? Products { get; set; }
|
public List<ProductInPurchaseBindingModel>? Products { get; set; }
|
||||||
public List<string>? ProductSetIds { get; set; }
|
public List<string>? ProductSetIds { get; set; }
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace YAPContracts.BindingModels
|
namespace YAPContracts.BindingModels
|
||||||
{
|
{
|
||||||
public class UserBindingModel
|
public class StorekeeperBindingModel
|
||||||
{
|
{
|
||||||
|
public string? Id { get; set; }
|
||||||
public string? Login { get; set; }
|
public string? Login { get; set; }
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public List<string>? ProductOrderIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class WorkerBindingModel
|
||||||
|
{
|
||||||
|
public string? Id { get; set; }
|
||||||
|
public string? Login { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public List<string>? PurchaseIds { get; set; }
|
||||||
|
|
||||||
|
public List<string>? CommentIds { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,11 +9,11 @@ using YAPContracts.Infrastructure;
|
|||||||
|
|
||||||
namespace YAPContracts.DataModels
|
namespace YAPContracts.DataModels
|
||||||
{
|
{
|
||||||
public class ComponentInProductSetDataModel(string componentId, string productSetId, int amount) : IValidation
|
public class ComponentInProductSetDataModel(string componentId, string productSetId, int price) : IValidation
|
||||||
{
|
{
|
||||||
public string ComponentId { get; private set; } = componentId;
|
public string ComponentId { get; private set; } = componentId;
|
||||||
public string ProductSetId { get; private set; } = productSetId;
|
public string ProductSetId { get; private set; } = productSetId;
|
||||||
public int Amount { get; private set; } = amount;
|
public int Price { get; private set; } = price;
|
||||||
|
|
||||||
public void Validate()
|
public void Validate()
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ namespace YAPContracts.DataModels
|
|||||||
{
|
{
|
||||||
throw new ValidationException("ProductSetId value is not valid");
|
throw new ValidationException("ProductSetId value is not valid");
|
||||||
}
|
}
|
||||||
if (Amount <= 0)
|
if (Price <= 0)
|
||||||
{
|
{
|
||||||
throw new ValidationException("Amount is less than or equal to 0");
|
throw new ValidationException("Amount is less than or equal to 0");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YAPContracts.Infrastructure
|
||||||
|
{
|
||||||
|
public class OperationResponse
|
||||||
|
{
|
||||||
|
protected HttpStatusCode StatusCode { get; set; }
|
||||||
|
|
||||||
|
protected object? Result { get; set; }
|
||||||
|
|
||||||
|
public IActionResult GetResponse(HttpRequest request, HttpResponse response)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(request);
|
||||||
|
ArgumentNullException.ThrowIfNull(response);
|
||||||
|
|
||||||
|
response.StatusCode = (int)StatusCode;
|
||||||
|
|
||||||
|
if (Result is null)
|
||||||
|
{
|
||||||
|
return new StatusCodeResult((int)StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ObjectResult(Result);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static TResult OK<TResult, TData>(TData data) where TResult : OperationResponse, new() => new() { StatusCode = HttpStatusCode.OK, Result = data };
|
||||||
|
|
||||||
|
protected static TResult NoContent<TResult>() where TResult : OperationResponse, new() => new() { StatusCode = HttpStatusCode.NoContent };
|
||||||
|
|
||||||
|
protected static TResult BadRequest<TResult>(string? errorMessage = null) where TResult : OperationResponse, new() => new() { StatusCode = HttpStatusCode.BadRequest, Result = errorMessage };
|
||||||
|
|
||||||
|
protected static TResult NotFound<TResult>(string? errorMessage = null) where TResult : OperationResponse, new() => new() { StatusCode = HttpStatusCode.NotFound, Result = errorMessage };
|
||||||
|
|
||||||
|
protected static TResult InternalServerError<TResult>(string? errorMessage = null) where TResult : OperationResponse, new() => new() { StatusCode = HttpStatusCode.InternalServerError, Result = errorMessage };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,6 @@ namespace YAPContracts.ViewModels
|
|||||||
public string Text { get; set; } = default!;
|
public string Text { get; set; } = default!;
|
||||||
public DateTime CommentDate { get; set; }
|
public DateTime CommentDate { get; set; }
|
||||||
|
|
||||||
public UserViewModel? Author { get; set; }
|
public WorkerViewModel? Author { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ namespace YAPContracts.ViewModels
|
|||||||
public string Id { get; set; } = default!;
|
public string Id { get; set; } = default!;
|
||||||
public DateTime OrderDate { get; set; }
|
public DateTime OrderDate { get; set; }
|
||||||
public string DealerName { get; set; } = default!;
|
public string DealerName { get; set; } = default!;
|
||||||
public UserViewModel? Author { get; set; }
|
public StorekeeperViewModel? Author { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YAPContracts.ViewModels
|
|||||||
public string SetName { get; set; } = default!;
|
public string SetName { get; set; } = default!;
|
||||||
public double TotalPrice { get; set; }
|
public double TotalPrice { get; set; }
|
||||||
|
|
||||||
public List<ComponentViewModel> Components { get; set; } = new();
|
public List<ComponentViewModel>? Components { get; set; }
|
||||||
public List<CommentViewModel> Comments { get; set; } = new();
|
public List<CommentViewModel>? Comments { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace YAPContracts.ViewModels
|
|||||||
public string Id { get; set; } = default!;
|
public string Id { get; set; } = default!;
|
||||||
public string Name { get; set; } = default!;
|
public string Name { get; set; } = default!;
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
public List<ComponentViewModel> Components { get; set; } = new();
|
public List<ComponentViewModel>? Components { get; set; }
|
||||||
public List<ProductOrderViewModel> ProductOrders { get; set; } = new();
|
public List<ProductOrderViewModel>? ProductOrders { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,15 @@ namespace YAPContracts.ViewModels
|
|||||||
public class PurchaseViewModel
|
public class PurchaseViewModel
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = default!;
|
public string Id { get; set; } = default!;
|
||||||
public DateTime PurchaseDate { get; set; }
|
|
||||||
public double TotalPrice { get; set; }
|
public double TotalPrice { get; set; }
|
||||||
|
|
||||||
public UserViewModel? User { get; set; }
|
public DateTime PurchaseDate { get; set; }
|
||||||
|
|
||||||
public List<ProductInPurchaseViewModel> Products { get; set; } = new();
|
public WorkerViewModel? User { get; set; }
|
||||||
|
|
||||||
public List<ProductSetViewModel> ProductSets { get; set; } = new();
|
public List<ProductInPurchaseViewModel>? Products { get; set; }
|
||||||
|
|
||||||
|
public List<ProductSetViewModel>? ProductSets { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ using YAPContracts.Enums;
|
|||||||
|
|
||||||
namespace YAPContracts.ViewModels
|
namespace YAPContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class UserViewModel
|
public class StorekeeperViewModel
|
||||||
{
|
{
|
||||||
public string Id { get; set; } = default!;
|
public string Id { get; set; } = default!;
|
||||||
public string Login { get; set; } = default!;
|
public string Login { get; set; } = default!;
|
||||||
public string Email { get; set; } = default!;
|
public string Email { get; set; } = default!;
|
||||||
public UserType Role { get; set; } // Worker / Storekeeper
|
public UserType Role { get; } = UserType.Worker;
|
||||||
|
|
||||||
|
public List<ProductOrderViewModel>? ProductOrders { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YAPContracts.Enums;
|
||||||
|
|
||||||
|
namespace YAPContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class WorkerViewModel
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = default!;
|
||||||
|
public string Login { get; set; } = default!;
|
||||||
|
public string Email { get; set; } = default!;
|
||||||
|
public UserType Role { get; } = UserType.Worker;
|
||||||
|
|
||||||
|
public List<PurchaseViewModel>? Purchases { get; set; }
|
||||||
|
|
||||||
|
public List<CommentViewModel>? Comments { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,4 +6,10 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
168
YouAreProgrammerShop/YAPWebAPI/Adapters/PurchaseAdapter.cs
Normal file
168
YouAreProgrammerShop/YAPWebAPI/Adapters/PurchaseAdapter.cs
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
namespace YAPWebAPI.Adapters
|
||||||
|
{
|
||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
using YAPContracts.DataModels;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
using YAPContracts.BusinessLogicContracts;
|
||||||
|
using YAPContracts.Exceptions;
|
||||||
|
using YAPContracts.AdapterContracts.OperationResponses;
|
||||||
|
using YAPContracts.AdapterContracts;
|
||||||
|
|
||||||
|
public class PurchaseAdapter : IPurchaseAdapter
|
||||||
|
{
|
||||||
|
private readonly IPurchaseBusinessLogicContract _purchaseBusinessLogicContract;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly Mapper _mapper;
|
||||||
|
|
||||||
|
public PurchaseAdapter(IPurchaseBusinessLogicContract purchaseBusinessLogicContract, ILogger logger)
|
||||||
|
{
|
||||||
|
_purchaseBusinessLogicContract = purchaseBusinessLogicContract;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
var config = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<PurchaseBindingModel, PurchaseDataModel>();
|
||||||
|
cfg.CreateMap<PurchaseDataModel, PurchaseViewModel>();
|
||||||
|
cfg.CreateMap<PurchaseViewModel, PurchaseDataModel>();
|
||||||
|
});
|
||||||
|
_mapper = new Mapper(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse GetList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.OK([.. _purchaseBusinessLogicContract.GetAllPurchases()
|
||||||
|
.Select(x => _mapper.Map<PurchaseViewModel>(x))]);
|
||||||
|
}
|
||||||
|
catch (NullListException)
|
||||||
|
{
|
||||||
|
_logger.LogError("NullListException");
|
||||||
|
return PurchaseOperationResponse.NotFound("The list is not initialized");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse GetElement(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.OK(
|
||||||
|
_mapper.Map<PurchaseViewModel>(_purchaseBusinessLogicContract.GetPurchaseByData(id))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (ArgumentNullException)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.BadRequest("Id is empty");
|
||||||
|
}
|
||||||
|
catch (ElementNotFoundException)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.NotFound($"Not found purchase by Id {id}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse GetByUserAndPeriod(string userId, DateTime fromDate, DateTime toDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.OK([.. _purchaseBusinessLogicContract
|
||||||
|
.GetPurchasesByUserByPeriod(userId, fromDate, toDate)
|
||||||
|
.Select(x => _mapper.Map<PurchaseViewModel>(x))]);
|
||||||
|
}
|
||||||
|
catch (IncorrectDatesException ex)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.BadRequest($"Incorrect date interval: {ex.Message}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse GetByPeriod(DateTime fromDate, DateTime toDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.OK([.. _purchaseBusinessLogicContract
|
||||||
|
.GetPurchasesByPeriod(fromDate, toDate)
|
||||||
|
.Select(x => _mapper.Map<PurchaseViewModel>(x))]);
|
||||||
|
}
|
||||||
|
catch (IncorrectDatesException ex)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.BadRequest($"Incorrect date interval: {ex.Message}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse InsertPurchase(PurchaseBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_purchaseBusinessLogicContract.InsertPurchase(_mapper.Map<PurchaseDataModel>(model));
|
||||||
|
return PurchaseOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (ValidationException ex)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.BadRequest($"Incorrect data: {ex.Message}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse UpdatePurchase(PurchaseBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_purchaseBusinessLogicContract.UpdatePurchase(_mapper.Map<PurchaseDataModel>(model));
|
||||||
|
return PurchaseOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (ElementNotFoundException)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.NotFound($"Purchase not found by Id {model.Id}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PurchaseOperationResponse DeletePurchase(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_purchaseBusinessLogicContract.DeletePurchase(id);
|
||||||
|
return PurchaseOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (ElementNotFoundException)
|
||||||
|
{
|
||||||
|
return PurchaseOperationResponse.NotFound($"Purchase not found by Id {id}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Exception");
|
||||||
|
return PurchaseOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
103
YouAreProgrammerShop/YAPWebAPI/Adapters/StorekeeperAdapter.cs
Normal file
103
YouAreProgrammerShop/YAPWebAPI/Adapters/StorekeeperAdapter.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using YAPContracts.AdapterContracts.OperationResponses;
|
||||||
|
using YAPContracts.AdapterContracts;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
using YAPContracts.BusinessLogicContracts;
|
||||||
|
using YAPContracts.DataModels.UserRoles;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace YAPWebAPI.Adapters
|
||||||
|
{
|
||||||
|
public class StorekeeperAdapter : IStorekeeperAdapter
|
||||||
|
{
|
||||||
|
private readonly IStorekeeperBusinessLogicContract _storekeeperBusinessLogic;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly Mapper _mapper;
|
||||||
|
|
||||||
|
public StorekeeperAdapter(IStorekeeperBusinessLogicContract storekeeperBusinessLogic, ILogger logger)
|
||||||
|
{
|
||||||
|
_storekeeperBusinessLogic = storekeeperBusinessLogic;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
var config = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<StorekeeperBindingModel, StorekeeperDataModel>();
|
||||||
|
cfg.CreateMap<StorekeeperDataModel, StorekeeperViewModel>();
|
||||||
|
cfg.CreateMap<StorekeeperViewModel, StorekeeperDataModel>();
|
||||||
|
});
|
||||||
|
_mapper = new Mapper(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorekeeperOperationResponse GetList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return StorekeeperOperationResponse.OK(
|
||||||
|
[.. _storekeeperBusinessLogic.GetAllStorekeepers().Select(x => _mapper.Map<StorekeeperViewModel>(x))]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in GetList");
|
||||||
|
return StorekeeperOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorekeeperOperationResponse GetElement(string data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return StorekeeperOperationResponse.OK(
|
||||||
|
_mapper.Map<StorekeeperViewModel>(_storekeeperBusinessLogic.GetStorekeeperByData(data))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in GetElement");
|
||||||
|
return StorekeeperOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorekeeperOperationResponse Register(StorekeeperBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storekeeperBusinessLogic.InsertStorekeeper(_mapper.Map<StorekeeperDataModel>(model));
|
||||||
|
return StorekeeperOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in Register");
|
||||||
|
return StorekeeperOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorekeeperOperationResponse Update(StorekeeperBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storekeeperBusinessLogic.UpdateStorekeeper(_mapper.Map<StorekeeperDataModel>(model));
|
||||||
|
return StorekeeperOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in Update");
|
||||||
|
return StorekeeperOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorekeeperOperationResponse Delete(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_storekeeperBusinessLogic.DeleteStorekeeper(id);
|
||||||
|
return StorekeeperOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in Delete");
|
||||||
|
return StorekeeperOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
103
YouAreProgrammerShop/YAPWebAPI/Adapters/WorkerAdapter.cs
Normal file
103
YouAreProgrammerShop/YAPWebAPI/Adapters/WorkerAdapter.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using YAPContracts.AdapterContracts.OperationResponses;
|
||||||
|
using YAPContracts.AdapterContracts;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
using YAPContracts.BusinessLogicContracts;
|
||||||
|
using YAPContracts.DataModels.UserRoles;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace YAPWebAPI.Adapters
|
||||||
|
{
|
||||||
|
public class WorkerAdapter : IWorkerAdapter
|
||||||
|
{
|
||||||
|
private readonly IWorkerBusinessLogicContract _workerBusinessLogic;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly Mapper _mapper;
|
||||||
|
|
||||||
|
public WorkerAdapter(IWorkerBusinessLogicContract workerBusinessLogic, ILogger logger)
|
||||||
|
{
|
||||||
|
_workerBusinessLogic = workerBusinessLogic;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
var config = new MapperConfiguration(cfg =>
|
||||||
|
{
|
||||||
|
cfg.CreateMap<WorkerBindingModel, WorkerDataModel>();
|
||||||
|
cfg.CreateMap<WorkerDataModel, WorkerViewModel>();
|
||||||
|
cfg.CreateMap<WorkerViewModel, WorkerDataModel>();
|
||||||
|
});
|
||||||
|
_mapper = new Mapper(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkerOperationResponse GetList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return WorkerOperationResponse.OK(
|
||||||
|
[.. _workerBusinessLogic.GetAllWorkers().Select(x => _mapper.Map<WorkerViewModel>(x))]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in GetList");
|
||||||
|
return WorkerOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkerOperationResponse GetElement(string data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return WorkerOperationResponse.OK(
|
||||||
|
_mapper.Map<WorkerViewModel>(_workerBusinessLogic.GetWorkerByData(data))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in GetElement");
|
||||||
|
return WorkerOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkerOperationResponse Register(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_workerBusinessLogic.InsertWorker(_mapper.Map<WorkerDataModel>(model));
|
||||||
|
return WorkerOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in Register");
|
||||||
|
return WorkerOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkerOperationResponse Update(WorkerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_workerBusinessLogic.UpdateWorker(_mapper.Map<WorkerDataModel>(model));
|
||||||
|
return WorkerOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in Update");
|
||||||
|
return WorkerOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkerOperationResponse Delete(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_workerBusinessLogic.DeleteWorker(id);
|
||||||
|
return WorkerOperationResponse.NoContent();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error in Delete");
|
||||||
|
return WorkerOperationResponse.InternalServerError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using YAPContracts.AdapterContracts;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
using YAPContracts.BusinessLogicContracts;
|
||||||
|
using YAPContracts.DataModels;
|
||||||
|
using YAPContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace YAPWebAPI.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public class PurchaseController(IPurchaseAdapter adapter) : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IPurchaseAdapter _adapter = adapter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить все покупки
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult GetAll()
|
||||||
|
{
|
||||||
|
return _adapter.GetList().GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить покупку по Id
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public IActionResult GetById(string id)
|
||||||
|
{
|
||||||
|
return _adapter.GetElement(id).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить покупки по пользователю за период
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("byUser/{userId}")]
|
||||||
|
public IActionResult GetByUserAndPeriod(string userId, DateTime fromDate, DateTime toDate)
|
||||||
|
{
|
||||||
|
return _adapter.GetByUserAndPeriod(userId, fromDate, toDate).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить покупки за период
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet("byPeriod")]
|
||||||
|
public IActionResult GetByPeriod(DateTime fromDate, DateTime toDate)
|
||||||
|
{
|
||||||
|
return _adapter.GetByPeriod(fromDate, toDate).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавить покупку
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Create([FromBody] PurchaseBindingModel model)
|
||||||
|
{
|
||||||
|
return _adapter.InsertPurchase(model).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Обновить покупку
|
||||||
|
/// </summary>
|
||||||
|
[HttpPut]
|
||||||
|
public IActionResult Update([FromBody] PurchaseBindingModel model)
|
||||||
|
{
|
||||||
|
return _adapter.UpdatePurchase(model).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Удалить покупку
|
||||||
|
/// </summary>
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public IActionResult Delete(string id)
|
||||||
|
{
|
||||||
|
return _adapter.DeletePurchase(id).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using YAPContracts.AdapterContracts;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace YAPWebAPI.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public class StorekeeperController(IStorekeeperAdapter adapter) : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IStorekeeperAdapter _adapter = adapter;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult GetAllStorekeepers()
|
||||||
|
=> _adapter.GetList().GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public IActionResult GetStorekeeper(string id)
|
||||||
|
=> _adapter.GetElement(id).GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Register([FromBody] StorekeeperBindingModel model)
|
||||||
|
=> _adapter.Register(model).GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public IActionResult Update([FromBody] StorekeeperBindingModel model)
|
||||||
|
=> _adapter.Update(model).GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public IActionResult Delete(string id)
|
||||||
|
=> _adapter.Delete(id).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using YAPContracts.AdapterContracts;
|
||||||
|
using YAPContracts.BindingModels;
|
||||||
|
|
||||||
|
namespace YAPWebAPI.Controllers
|
||||||
|
{
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public class WorkerController(IWorkerAdapter adapter) : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IWorkerAdapter _adapter = adapter;
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult GetAllWorkers()
|
||||||
|
=> _adapter.GetList().GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public IActionResult GetWorker(string id)
|
||||||
|
=> _adapter.GetElement(id).GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Register([FromBody] WorkerBindingModel model)
|
||||||
|
=> _adapter.Register(model).GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpPut]
|
||||||
|
public IActionResult Update([FromBody] WorkerBindingModel model)
|
||||||
|
=> _adapter.Update(model).GetResponse(Request, Response);
|
||||||
|
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public IActionResult Delete(string id)
|
||||||
|
=> _adapter.Delete(id).GetResponse(Request, Response);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user