ПРОВЕРЯЮ ЧЕРЕЗ SWAGGER
This commit is contained in:
parent
ea3aa4bf96
commit
3751080250
@ -27,7 +27,8 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
//model.UserId = -1 для swagger, чтобы можно было считать все заказы всех пользователей
|
||||||
|
var list = (model == null || model.UserId == -1) ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@ -73,11 +74,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
public bool Create(OrderBindingModel model)
|
public bool Create(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (model.Status != OrderStatus.Неизвестен)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Invalid order status");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
model.Status = OrderStatus.Принят;
|
model.Status = OrderStatus.Принят;
|
||||||
if (_orderStorage.Insert(model) == null)
|
if (_orderStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
@ -102,14 +98,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//!!!ПРОВЕРИТЬ
|
|
||||||
//if (model.Status != null & ChangeStatus(model, order.Status))
|
|
||||||
//{
|
|
||||||
// ordee.DateCreate[model.DateCreate;
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
//model.Status = order.Status;
|
|
||||||
//model.Sum = order.Sum;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -24,7 +25,8 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<RequestViewModel>? ReadList(RequestSearchModel? model)
|
public List<RequestViewModel>? ReadList(RequestSearchModel? model)
|
||||||
{
|
{
|
||||||
var list = model == null ? _requestStorage.GetFullList() : _requestStorage.GetFilteredList(model);
|
//model.UserId = -1 для swagger, чтобы можно было считать все заявки всех пользователей
|
||||||
|
var list = (model == null || model.UserId == -1) ? _requestStorage.GetFullList() : _requestStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList requests return null list");
|
_logger.LogWarning("ReadList requests return null list");
|
||||||
@ -73,6 +75,13 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!!!ПРОВЕРИТЬ
|
||||||
|
public bool ConnectRequestAssembly(int requestId, int assemblyId)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Connect Assembly {rId} with request {aId}", requestId, assemblyId);
|
||||||
|
return _requestStorage.ConnectRequestAssembly(requestId, assemblyId);
|
||||||
|
}
|
||||||
|
|
||||||
public bool Delete(RequestBindingModel model)
|
public bool Delete(RequestBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
|
@ -28,8 +28,8 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
|||||||
//!!!ИЛИ СОЗДАТЬ ОТДЕЛЬНЫЙ МЕТОД ReadListUser
|
//!!!ИЛИ СОЗДАТЬ ОТДЕЛЬНЫЙ МЕТОД ReadListUser
|
||||||
public List<ShipmentViewModel> ReadList(ShipmentSearchModel? model)
|
public List<ShipmentViewModel> ReadList(ShipmentSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ShipmentId:{Id}", model?.Id);
|
//model.UserId = -1 для swagger, чтобы можно было считать все партии товаров всех пользователей
|
||||||
var list = model == null ? _shipmentStorage.GetFullList() : _shipmentStorage.GetFilteredList(model);
|
var list = (model == null || model.UserId == -1) ? _shipmentStorage.GetFullList() : _shipmentStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
@ -17,5 +17,6 @@ namespace ComputerShopContracts.BusinessLogicContracts
|
|||||||
bool Create(RequestBindingModel model);
|
bool Create(RequestBindingModel model);
|
||||||
bool Update(RequestBindingModel model);
|
bool Update(RequestBindingModel model);
|
||||||
bool Delete(RequestBindingModel model);
|
bool Delete(RequestBindingModel model);
|
||||||
|
bool ConnectRequestAssembly(int requestId, int assemblyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace ComputerShopContracts.SearchModels
|
|||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Login { get; set; }
|
public string? Login { get; set; }
|
||||||
|
|
||||||
//!!!ПОИСК ПО ПАРОЛЮ НЕ СТАЛ ДОБАВЛЯТЬ, ИБО СТРАННО
|
public string Password { get; set; }
|
||||||
|
|
||||||
public string? Email { get; set; }
|
public string? Email { get; set; }
|
||||||
public UserRole? Role { get; set; }
|
public UserRole? Role { get; set; }
|
||||||
|
@ -17,5 +17,6 @@ namespace ComputerShopContracts.StorageContracts
|
|||||||
RequestViewModel? Insert(RequestBindingModel model);
|
RequestViewModel? Insert(RequestBindingModel model);
|
||||||
RequestViewModel? Update(RequestBindingModel model);
|
RequestViewModel? Update(RequestBindingModel model);
|
||||||
RequestViewModel? Delete(RequestBindingModel model);
|
RequestViewModel? Delete(RequestBindingModel model);
|
||||||
|
bool ConnectRequestAssembly(int requestId, int assemblyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ namespace ComputerShopContracts.ViewModels
|
|||||||
public int? AssemblyId { get; set; }
|
public int? AssemblyId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//!!!МБ НАДО БУДЕТ ПРИВЯЗЫВАТЬ НАЗВАНИЕ СБОРКИ И Т.Д. ДЛЯ ОТЧЁТОВ
|
public IAssemblyModel? Assembly { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
public Dictionary<int, IOrderModel> RequestOrders { get; set; } = new();
|
||||||
|
|
||||||
|
@ -148,5 +148,20 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!!!ПРОВЕРИТЬ
|
||||||
|
public bool ConnectRequestAssembly(int requestId, int assemblyId)
|
||||||
|
{
|
||||||
|
using var context = new ComputerShopDatabase();
|
||||||
|
var request = context.Requests.FirstOrDefault(x => x.Id == requestId);
|
||||||
|
var assembly = context.Assemblies.FirstOrDefault(x => x.Id == assemblyId);
|
||||||
|
if (request == null || assembly == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
request.ConnectAssembly(context, assemblyId);
|
||||||
|
context.SaveChanges();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,19 @@ namespace ComputerShopDatabaseImplement.Implements
|
|||||||
//id, почта и логин уникальны, можно получать по ним
|
//id, почта и логин уникальны, можно получать по ним
|
||||||
public UserViewModel? GetElement(UserSearchModel model)
|
public UserViewModel? GetElement(UserSearchModel model)
|
||||||
{
|
{
|
||||||
|
//!!!МБ ЭТУ ПРОВЕРКУ УБРАТЬ
|
||||||
if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
if (string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
|
|
||||||
|
//Поиск пользователя при входе в систему по логину, паролю и его роли (чтобы не могли войти в аккаунты другой роли)
|
||||||
|
if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && model.Role.HasValue)
|
||||||
|
{
|
||||||
|
return context.Users.FirstOrDefault(x => x.Login == model.Login && x.Password == model.Password && x.Role == model.Role)?.GetViewModel;
|
||||||
|
}
|
||||||
|
//!!!НИЖЕ МБ НЕ НАДО
|
||||||
//Получение по логину (пользователей с таким логином будет 1 или 0)
|
//Получение по логину (пользователей с таким логином будет 1 или 0)
|
||||||
if (!string.IsNullOrEmpty(model.Login))
|
if (!string.IsNullOrEmpty(model.Login))
|
||||||
{
|
{
|
||||||
|
@ -77,21 +77,32 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
if (model == null) {
|
if (model == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (model.DateRequest != null)
|
||||||
|
{
|
||||||
|
DateRequest = model.DateRequest;
|
||||||
|
}
|
||||||
using var context = new ComputerShopDatabase();
|
using var context = new ComputerShopDatabase();
|
||||||
DateRequest = model.DateRequest;
|
//if (model.AssemblyId.HasValue && model.AssemblyId > 0)
|
||||||
AssemblyId = model.AssemblyId.HasValue ? model.AssemblyId : AssemblyId;
|
//{
|
||||||
Assembly = model.AssemblyId.HasValue ? context.Assemblies.First(x => x.Id == model.AssemblyId) : Assembly;
|
// AssemblyId = model.AssemblyId;
|
||||||
ClientFIO = model.ClientFIO;
|
// Assembly = context.Assemblies.FirstOrDefault(x => x.Id == model.AssemblyId);
|
||||||
|
//}
|
||||||
|
if (!string.IsNullOrEmpty(model.ClientFIO))
|
||||||
|
{
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
//!!!МБ ТУТ НЕ ВСЁ НАДО ПРИСВАИВАТЬ
|
//!!!МБ ТУТ НАДО ПРИСВАИВАТЬ ЗНАЧЕНИЕ Assembly
|
||||||
public RequestViewModel GetViewModel => new()
|
public RequestViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
UserId = UserId,
|
UserId = UserId,
|
||||||
AssemblyId = AssemblyId,
|
AssemblyId = AssemblyId,
|
||||||
|
Assembly = Assembly,
|
||||||
DateRequest = DateRequest,
|
DateRequest = DateRequest,
|
||||||
ClientFIO = ClientFIO
|
ClientFIO = ClientFIO,
|
||||||
|
RequestOrders = RequestOrders
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -122,5 +133,12 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
_requestOrders = null;
|
_requestOrders = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!!!ПРОВЕРИТЬ
|
||||||
|
public void ConnectAssembly(ComputerShopDatabase context, int assemblyId)
|
||||||
|
{
|
||||||
|
AssemblyId = assemblyId;
|
||||||
|
Assembly = context.Assemblies.First(x => x.Id == assemblyId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
private Dictionary<int, IOrderModel>? _shipmentOrders = null;
|
private Dictionary<int, IOrderModel>? _shipmentOrders = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, IOrderModel>? ShipmentOrders
|
public Dictionary<int, IOrderModel> ShipmentOrders
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -58,6 +58,7 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
UserId = model.UserId,
|
UserId = model.UserId,
|
||||||
|
User = context.Users.First(x => x.Id == model.UserId),
|
||||||
ProviderName = model.ProviderName,
|
ProviderName = model.ProviderName,
|
||||||
DateShipment = model.DateShipment,
|
DateShipment = model.DateShipment,
|
||||||
Orders = model.ShipmentOrders.Select(x => new ShipmentOrder
|
Orders = model.ShipmentOrders.Select(x => new ShipmentOrder
|
||||||
@ -69,8 +70,18 @@ namespace ComputerShopDatabaseImplement.Models
|
|||||||
//!!!МБ ТУТ КАКИЕ-ТО ДРУГИЕ ПОЛЯ НАДО БУДЕТ ОБНОВЛЯТЬ
|
//!!!МБ ТУТ КАКИЕ-ТО ДРУГИЕ ПОЛЯ НАДО БУДЕТ ОБНОВЛЯТЬ
|
||||||
public void Update(ShipmentBindingModel model)
|
public void Update(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
ProviderName = model.ProviderName;
|
if (model == null)
|
||||||
DateShipment = model.DateShipment;
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.ProviderName))
|
||||||
|
{
|
||||||
|
ProviderName = model.ProviderName;
|
||||||
|
}
|
||||||
|
if (model.DateShipment != null)
|
||||||
|
{
|
||||||
|
DateShipment = model.DateShipment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//!!!МБ ТУТ ЕЩЁ ЧТО-ТО ПРИСВАИВАТЬ
|
//!!!МБ ТУТ ЕЩЁ ЧТО-ТО ПРИСВАИВАТЬ
|
||||||
public ShipmentViewModel GetViewModel => new()
|
public ShipmentViewModel GetViewModel => new()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ComputerShopContracts.BusinessLogicContracts;
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
using ComputerShopContracts.SearchModels;
|
using ComputerShopContracts.SearchModels;
|
||||||
using ComputerShopContracts.ViewModels;
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using ComputerShopDatabaseImplement.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ComputerShopRestApi.Controllers
|
namespace ComputerShopRestApi.Controllers
|
||||||
@ -36,6 +37,26 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение заказов по id пользователя (полный список, кот. будет выводиться)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public List<OrderViewModel>? GetOrders(int? userId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(new OrderSearchModel { UserId = userId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateOrder(OrderBindingModel model)
|
public void CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,8 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public RequestViewModel? GetRequest(int id)
|
public RequestViewModel? GetRequest(int id)
|
||||||
{
|
{
|
||||||
@ -35,6 +37,27 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение заявок по id пользователя (полный список, кот. будет выводиться)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public List<RequestViewModel>? GetRequests(int userId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(new RequestSearchModel { UserId = userId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateRequest(RequestBindingModel model)
|
public void CreateRequest(RequestBindingModel model)
|
||||||
{
|
{
|
||||||
@ -48,6 +71,23 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!!!ПРОВЕРИТЬ
|
||||||
|
[HttpPost]
|
||||||
|
public void ConnectRequestAssembly(int requestId, int assemblyId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.ConnectRequestAssembly(requestId, assemblyId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка связывания заявки со сборкой");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateRequest(RequestBindingModel model)
|
public void UpdateRequest(RequestBindingModel model)
|
||||||
{
|
{
|
||||||
@ -61,7 +101,10 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//!!!мб HttpPut
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public void DeleteRequest(RequestBindingModel model)
|
public void DeleteRequest(RequestBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ShipmentViewModel? GetShipment(int id)
|
public ShipmentViewModel? GetShipment(int id)
|
||||||
{
|
{
|
||||||
@ -37,6 +38,27 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение партий по id пользователя (полный список, кот. будет выводиться)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public List<ShipmentViewModel>? GetShipments(int userId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadList(new ShipmentSearchModel { UserId = userId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateShipment(ShipmentBindingModel model)
|
public void CreateShipment(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
@ -50,6 +72,7 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateShipment(ShipmentBindingModel model)
|
public void UpdateShipment(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
@ -63,7 +86,7 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//!!!мб HttpPut
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public void DeleteShipment(ShipmentBindingModel model)
|
public void DeleteShipment(ShipmentBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ComputerShopContracts.BusinessLogicContracts;
|
using ComputerShopContracts.BusinessLogicContracts;
|
||||||
using ComputerShopContracts.SearchModels;
|
using ComputerShopContracts.SearchModels;
|
||||||
using ComputerShopContracts.ViewModels;
|
using ComputerShopContracts.ViewModels;
|
||||||
|
using ComputerShopDataModels.Enums;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ComputerShopRestApi.Controllers
|
namespace ComputerShopRestApi.Controllers
|
||||||
@ -18,17 +19,18 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
_logic = logic;
|
_logic = logic;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
//!!!мб тут нужен пароль
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public UserViewModel? Login(string login, string password)
|
public UserViewModel? LoginImplementer(string login, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _logic.ReadElement(new UserSearchModel
|
return _logic.ReadElement(new UserSearchModel
|
||||||
{
|
{
|
||||||
Login = login,
|
Login = login,
|
||||||
Email = login
|
Password = password,
|
||||||
|
Role = UserRole.Исполнитель
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -38,11 +40,47 @@ namespace ComputerShopRestApi.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpGet]
|
||||||
public void Register(UserBindingModel model)
|
public UserViewModel? LoginGuarantor(string login, string password)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
return _logic.ReadElement(new UserSearchModel
|
||||||
|
{
|
||||||
|
Login = login,
|
||||||
|
Password = password,
|
||||||
|
Role = UserRole.Поручитель
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка входа в систему");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//!!!мб не тут надо присваивать роль
|
||||||
|
[HttpPost]
|
||||||
|
public void RegisterImplementer(UserBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
model.Role = UserRole.Исполнитель;
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка регистрации");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void RegisterGuarantor(UserBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
model.Role = UserRole.Поручитель;
|
||||||
_logic.Create(model);
|
_logic.Create(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
Reference in New Issue
Block a user