dont work
This commit is contained in:
parent
dab4a0980f
commit
4f4ca4e948
@ -39,7 +39,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmployeeViewModel? ReadElemet(EmployeeSearchModel model) {
|
public EmployeeViewModel? ReadElement(EmployeeSearchModel model) {
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
namespace ElectronicsShopContracts.BusinessLogicContracts {
|
namespace ElectronicsShopContracts.BusinessLogicContracts {
|
||||||
public interface IEmployeeLogic {
|
public interface IEmployeeLogic {
|
||||||
List<EmployeeViewModel>? ReadList(EmployeeSearchModel model);
|
List<EmployeeViewModel>? ReadList(EmployeeSearchModel model);
|
||||||
EmployeeViewModel? ReadElemet(EmployeeSearchModel model);
|
EmployeeViewModel? ReadElement(EmployeeSearchModel model);
|
||||||
|
|
||||||
bool Create(EmployeeBindingModel model);
|
bool Create(EmployeeBindingModel model);
|
||||||
bool Update(EmployeeBindingModel model);
|
bool Update(EmployeeBindingModel model);
|
||||||
|
@ -3,6 +3,7 @@ using ElectronicsShopContracts.SearchModels;
|
|||||||
using ElectronicsShopContracts.StorageContracts;
|
using ElectronicsShopContracts.StorageContracts;
|
||||||
using ElectronicsShopContracts.ViewModels;
|
using ElectronicsShopContracts.ViewModels;
|
||||||
using ElectronicsShopDataBaseImplement.Models;
|
using ElectronicsShopDataBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
|
||||||
namespace ElectronicsShopDataBaseImplement.Implements
|
namespace ElectronicsShopDataBaseImplement.Implements
|
||||||
@ -46,15 +47,17 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
|||||||
|
|
||||||
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
|
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.Login) && !model.ID.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
return context.Employees
|
if (model.ID.HasValue) {
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Login) &&
|
return context.Employees
|
||||||
x.EmployeeFIO == model.EmployeFIO ||
|
.FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)?.GetViewModel;
|
||||||
(model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password)) {
|
||||||
|
return context.Employees
|
||||||
|
.FirstOrDefault(x => (x.Login == model.Login && x.Password == model.Password))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
|
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
|
||||||
|
@ -16,7 +16,7 @@ namespace ElectronicsShopEmployeeApp.Controllers {
|
|||||||
if (APIEmployee.Employee == null) {
|
if (APIEmployee.Employee == null) {
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View(APIEmployee.GetRequset<List<ProductViewModel>>($"api/main/getproducts"));
|
return View(APIEmployee.GetRequset<List<ProductViewModel>>($"api/main/getproducts?_employeeid={APIEmployee.Employee.ID}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -58,11 +58,12 @@ namespace ElectronicsShopEmployeeApp.Controllers {
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
public void Enter(string login, string password) {
|
public void Enter(string login, string password) {
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) {
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) {
|
||||||
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
|
throw new Exception("Ââåäèòå ëîãèí è ïàðîëü");
|
||||||
}
|
}
|
||||||
APIEmployee.Employee = APIEmployee.GetRequset<EmployeeViewModel>($"api/employee/login/login={login}&password={password}");
|
APIEmployee.Employee = APIEmployee.GetRequset<EmployeeViewModel>($"api/employee/login?login={login}&password={password}");
|
||||||
if (APIEmployee.Employee == null) {
|
if (APIEmployee.Employee == null) {
|
||||||
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
|
||||||
}
|
}
|
||||||
@ -74,6 +75,7 @@ namespace ElectronicsShopEmployeeApp.Controllers {
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
public void Register(string login, string password, string fio) {
|
public void Register(string login, string password, string fio) {
|
||||||
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) {
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) {
|
||||||
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü è ÔÈÎ");
|
||||||
@ -95,7 +97,6 @@ namespace ElectronicsShopEmployeeApp.Controllers {
|
|||||||
|
|
||||||
public void Create(OrderBindingModel order) {
|
public void Create(OrderBindingModel order) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<div class="col-4">Логин:</div>
|
||||||
<div class="col-8"><input type="text" name="Login" /></div>
|
<div class="col-8"><input type="text" name="login" /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Пароль:</div>
|
<div class="col-4">Пароль:</div>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Почта:</div>
|
<div class="col-4">Логин:</div>
|
||||||
<div class="col-8"><input type="text" name="Login" /></div>
|
<div class="col-8"><input type="text" name="Login" /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -22,7 +22,7 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public EmployeeViewModel? Login(string login, string password) {
|
public EmployeeViewModel? Login(string login, string password) {
|
||||||
try {
|
try {
|
||||||
return _logic.ReadElemet(new EmployeeSearchModel {
|
return _logic.ReadElement(new EmployeeSearchModel {
|
||||||
Login = login,
|
Login = login,
|
||||||
Password = password
|
Password = password
|
||||||
});
|
});
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
using ElectronicsShopContracts.BindingModels;
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.BusinessLogicContracts;
|
||||||
|
using ElectronicsShopContracts.SearchModels;
|
||||||
using ElectronicsShopContracts.ViewModels;
|
using ElectronicsShopContracts.ViewModels;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace ElectronicsShopResrAPI.Controllers {
|
namespace ElectronicsShopRestAPI.Controllers {
|
||||||
|
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class MainController : Controller {
|
public class MainController : Controller {
|
||||||
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly IProductLogic _product;
|
||||||
|
|
||||||
public MainController(ILogger<MainController> logger) {
|
public MainController(ILogger<MainController> logger, IProductLogic product) {
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_product = product;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -29,10 +33,21 @@ namespace ElectronicsShopResrAPI.Controllers {
|
|||||||
// клиент должен получать свои заказы
|
// клиент должен получать свои заказы
|
||||||
// сотрудник должен получать все заказы
|
// сотрудник должен получать все заказы
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<OrderViewModel>? GetOrders(int? userID = null) {
|
public List<OrderViewModel>? GetOrders(int _clientID) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<ProductViewModel>? GetProducts() {
|
||||||
|
try {
|
||||||
|
return _product.ReadList(new ProductSearchModel {});
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, $"Ошибка получения данных");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateOrder(OrderBindingModel model) {
|
public void CreateOrder(OrderBindingModel model) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
@ElectronicsShopResrAPI_HostAddress = http://localhost:5176
|
|
||||||
|
|
||||||
GET {{ElectronicsShopResrAPI_HostAddress}}/weatherforecast/
|
|
||||||
Accept: application/json
|
|
||||||
|
|
||||||
###
|
|
@ -0,0 +1,6 @@
|
|||||||
|
@ElectronicsShopRestAPI_HostAddress = http://localhost:5176
|
||||||
|
|
||||||
|
GET {{ElectronicsShopRestAPI_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
@ -11,8 +11,10 @@ var builder = WebApplication.CreateBuilder(args);
|
|||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
builder.Services.AddTransient<IEmployeeStorage, EmployeeStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
builder.Services.AddTransient<IEmployeeLogic, EmployeeLogic>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||||
<ul class="navbar-nav flex-grow-1">
|
<ul class="navbar-nav flex-grow-1">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Продукты</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user