hiiiiinases

This commit is contained in:
Игорь Гордеев 2024-05-27 18:33:24 +04:00
parent 4ab0533d8b
commit d8beafb61f
4 changed files with 22 additions and 14 deletions

View File

@ -9,6 +9,7 @@ namespace ElectronicsShopContracts.SearchModels
public class ClientSearchModel public class ClientSearchModel
{ {
public int? ID { get; set; } public int? ID { get; set; }
public string? ClientFIO { get; set; }
public string? Email { get; set; } public string? Email { get; set; }
public string? Passwrod { get; set; } public string? Passwrod { get; set; }
} }

View File

@ -76,20 +76,13 @@ namespace ElectronicsShopDataBaseImplement.Implements
return new(); return new();
} }
using var context = new Database(); using var context = new Database();
return context.Clients return context.Clients.Where(x=> x.ClientFIO.Contains(model.ClientFIO)).Select(x => x.GetViewModel).ToList();
.Include(x => x.Orders)
.Where(x => x.Email
.Contains(model.Email))
.Select(x => x.GetViewModel).ToList();
} }
public List<ClientViewModel> GetFullList() public List<ClientViewModel> GetFullList()
{ {
using var context = new Database(); using var context = new Database();
return context.Clients return context.Clients.Select(x => x.GetViewModel).ToList();
.Include(x => x.Orders)
.Select(x => x.GetViewModel)
.ToList();
} }
} }
} }

View File

@ -2,6 +2,7 @@
using ElectronicsShopContracts.BusinessLogicContracts; using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels; using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.ViewModels; using ElectronicsShopContracts.ViewModels;
using ElectronicsShopDataBaseImplement.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace ElectronicsShopRestAPI.Controllers { namespace ElectronicsShopRestAPI.Controllers {
@ -12,10 +13,12 @@ namespace ElectronicsShopRestAPI.Controllers {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IProductLogic _product; private readonly IProductLogic _product;
private readonly IOrderLogic _order;
public MainController(ILogger<MainController> logger, IProductLogic product) { public MainController(ILogger<MainController> logger, IProductLogic product, IOrderLogic orderLogic) {
_logger = logger; _logger = logger;
_product = product; _product = product;
_order = orderLogic;
} }
[HttpGet] [HttpGet]
@ -25,8 +28,8 @@ namespace ElectronicsShopRestAPI.Controllers {
} }
[HttpGet] [HttpGet]
public ProductViewModel? GetProduct(int ProductID) { public ProductViewModel? GetProduct(int ProductID) {
return null; return null;
} }
@ -34,7 +37,18 @@ namespace ElectronicsShopRestAPI.Controllers {
// сотрудник должен получать все заказы // сотрудник должен получать все заказы
[HttpGet] [HttpGet]
public List<OrderViewModel>? GetOrders(int _clientID) { public List<OrderViewModel>? GetOrders(int _clientID) {
return null; try
{
return _order.ReadList(new OrderSearchModel
{
ID = _clientID
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка заказов клиента id = {Id} ", _clientID);
throw;
}
} }
[HttpGet] [HttpGet]

View File

@ -64,7 +64,7 @@ namespace ElectronicsShopUserApp.Controllers {
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) {
throw new Exception("Ââåäèòå ïî÷òó è ïàðîëü"); throw new Exception("Ââåäèòå ïî÷òó è ïàðîëü");
} }
APIClient.Client = APIClient.GetRequset<ClientViewModel>($"api/client/email/email={email}&password={password}"); APIClient.Client = APIClient.GetRequset<ClientViewModel>($"api/client/email?email={email}&password={password}");
if (APIClient.Client == null) { if (APIClient.Client == null) {
throw new Exception("Íåâåðíûé àäðåñ ïî÷òû/ïàðîëü"); throw new Exception("Íåâåðíûé àäðåñ ïî÷òû/ïàðîëü");
} }