поменял implement администратора, реализовал вход/регистрацию админа, а также частично таблицы
This commit is contained in:
parent
da4915672e
commit
c3c3770a20
135
CarCenter/CarCenterAdministratorAPP/AdministratorData.cs
Normal file
135
CarCenter/CarCenterAdministratorAPP/AdministratorData.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using CarCenterContracts.BusinessLogicsContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterDataBaseImplement.Models;
|
||||
|
||||
namespace AdministratorApp
|
||||
{
|
||||
public class AdministratorData
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IAdministratorLogic _administratorLogic;
|
||||
private readonly ICarSalesLogic _carSaleLogic;
|
||||
private readonly ICompletionsLogic _completionsLogic;
|
||||
private readonly IInspectionLogic _inspectionLogic;
|
||||
private readonly IEmployeeLogic _employeeLogic;
|
||||
|
||||
public AdministratorData(ILogger<AdministratorData> logger, IAdministratorLogic AdministratorLogic, ICarSalesLogic CarSaleLogic, ICompletionsLogic CompletionsLogic, IInspectionLogic InspectionLogic, IEmployeeLogic EmployeeLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_administratorLogic = AdministratorLogic;
|
||||
_carSaleLogic = CarSaleLogic;
|
||||
_completionsLogic = CompletionsLogic;
|
||||
_inspectionLogic = InspectionLogic;
|
||||
_employeeLogic = EmployeeLogic;
|
||||
}
|
||||
|
||||
public AdministratorViewModel? Login(string login, string password)
|
||||
{
|
||||
return _administratorLogic.ReadElement(new()
|
||||
{
|
||||
AdministratorLogin = login,
|
||||
AdministratorPassword = password
|
||||
});
|
||||
}
|
||||
public bool Register(AdministratorBindingModel model)
|
||||
{
|
||||
return _administratorLogic.Create(model);
|
||||
}
|
||||
public bool UpdateUser(AdministratorBindingModel model)
|
||||
{
|
||||
return _administratorLogic.Update(model);
|
||||
}
|
||||
|
||||
public List<CarSalesViewModel>? GetCarSales(int administratorId)
|
||||
{
|
||||
return _carSaleLogic.ReadList(new CarSalesSearchModel() { AdministratorId = administratorId });
|
||||
}
|
||||
public bool DeleteCarSale(int CarSaleId)
|
||||
{
|
||||
return _carSaleLogic.Delete(new() { Id = CarSaleId });
|
||||
}
|
||||
public bool CreateCarSale(CarSalesBindingModel model)
|
||||
{
|
||||
return _carSaleLogic.Create(model);
|
||||
}
|
||||
public bool UpdateCarSale(CarSalesBindingModel model)
|
||||
{
|
||||
return _carSaleLogic.Update(model);
|
||||
}
|
||||
public CarSalesViewModel? GetCarSale(int id)
|
||||
{
|
||||
return _carSaleLogic.ReadElement(new() { Id= id });
|
||||
}
|
||||
|
||||
public List<InspectionViewModel>? GetInspections(int administratorId)
|
||||
{
|
||||
return _inspectionLogic.ReadList(new InspectionSearchModel() { AdministratorId = administratorId });
|
||||
}
|
||||
public InspectionViewModel? GetInspection(int id)
|
||||
{
|
||||
return _inspectionLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public bool UpdateInspection(InspectionBindingModel model)
|
||||
{
|
||||
return _inspectionLogic.Update(model);
|
||||
}
|
||||
public bool DeleteInspection(int inspectionId)
|
||||
{
|
||||
return _inspectionLogic.Delete(new() { Id = inspectionId });
|
||||
}
|
||||
public bool CreateInspection(InspectionBindingModel model)
|
||||
{
|
||||
return _inspectionLogic.Create(model);
|
||||
}
|
||||
|
||||
public List<CompletionsViewModel>? GetCompletionss(int administratorId)
|
||||
{
|
||||
return _completionsLogic.ReadList(new() { AdministratorId = administratorId });
|
||||
}
|
||||
public CompletionsViewModel? GetCompletions(int id)
|
||||
{
|
||||
return _completionsLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public bool CreateCompletions(CompletionsBindingModel model)
|
||||
{
|
||||
return _completionsLogic.Create(model);
|
||||
}
|
||||
public bool UpdateCompletions(CompletionsBindingModel model)
|
||||
{
|
||||
return _completionsLogic.Update(model);
|
||||
}
|
||||
public bool DeleteCompletions(int CompletionsId)
|
||||
{
|
||||
return _completionsLogic.Delete(new() { Id = CompletionsId});
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel>? GetEmployees()
|
||||
{
|
||||
return _employeeLogic.ReadList(null);
|
||||
}
|
||||
|
||||
public List<CarsPeriodReportViewModel> GetTimeReport(DateTime? startDate, DateTime? endDate, int administratorId)
|
||||
{
|
||||
var CarSales = _carSaleLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, AdministratorId = administratorId });
|
||||
if (CarSales == null)
|
||||
return new();
|
||||
List<CarsPeriodReportViewModel> CarSaleTimeReports = new List<CarsPeriodReportViewModel>();
|
||||
foreach (var CarSale in CarSales)
|
||||
{
|
||||
var report = new CarsPeriodReportViewModel();
|
||||
report.CarBrand = CarSale.CarBrand;
|
||||
var Inspections = _inspectionLogic.ReadList(new() { CarSalesId = CarSale.Id, AdministratorId = administratorId });
|
||||
if (Inspections != null)
|
||||
report.Inspections = Inspections.Select(p => p.InspectionName).ToList();
|
||||
var Completions = _completionsLogic.ReadList(new() { CarSalesId = CarSale.Id, AdministratorId = administratorId });
|
||||
if (Completions != null)
|
||||
report.Completions = Completions.Select(p => p.СompletionName).ToList();
|
||||
CarSaleTimeReports.Add(report);
|
||||
}
|
||||
return CarSaleTimeReports;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="6.0.26" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.26" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,200 +1,354 @@
|
||||
using CarCenterAdministratorAPP.Models;
|
||||
using AdministratorApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using CarCenterBusinessLogic.BusinessLogics;
|
||||
using CarCenterContracts.BusinessLogicsContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Models;
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterDataBaseImplement.Models;
|
||||
|
||||
namespace ImplementerApp.Controllers
|
||||
namespace AdministratorApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly ICompletionsLogic _completionsLogic;
|
||||
private readonly IAdministratorLogic _adminLogic;
|
||||
private readonly ICarSalesLogic _carLogic;
|
||||
private readonly IInspectionLogic _inspectionLogic;
|
||||
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
private readonly AdministratorData _data;
|
||||
public HomeController(ILogger<HomeController> logger, AdministratorData data)
|
||||
{
|
||||
_logger = logger;
|
||||
_data = data;
|
||||
}
|
||||
private bool IsLoggedIn { get { return UserAdministrator.admin != null; } }
|
||||
private int AdminId { get { return UserAdministrator.admin!.Id; } }
|
||||
public IActionResult IndexNonReg()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return View();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
if (!IsLoggedIn)
|
||||
return View();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
[HttpPost]
|
||||
public void Enter(string login, string password)
|
||||
{
|
||||
var admin = _data.Login(login, password);
|
||||
if (admin != null)
|
||||
{
|
||||
UserAdministrator.admin = admin;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult IndexCompletions()
|
||||
public IActionResult Logout()
|
||||
{
|
||||
List<CompletionsViewModel> completions = new List<CompletionsViewModel>();
|
||||
completions.Add(new CompletionsViewModel
|
||||
{
|
||||
Id = 1,
|
||||
СompletionName = "Name1",
|
||||
СompletionFeatures = "Feature1",
|
||||
СompletionPrice = 500.0,
|
||||
AdministratorId = 1,
|
||||
СompletionCars = new()
|
||||
});
|
||||
completions.Add(new CompletionsViewModel
|
||||
{
|
||||
Id = 2,
|
||||
СompletionName = "Name2",
|
||||
СompletionFeatures = "Feature2",
|
||||
СompletionPrice = 1000.0,
|
||||
AdministratorId = 2
|
||||
});
|
||||
return View(completions);
|
||||
UserAdministrator.admin = null;
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
public IActionResult CreateCompletions()
|
||||
[HttpPost]
|
||||
public void Register(string fio, string login, string email, string number, string password1, string password2)
|
||||
{
|
||||
var cars = new List<CarSalesViewModel>();
|
||||
cars.Add(new CarSalesViewModel
|
||||
if (password1 == password2 && _data.Register(new() { AdministratorEmail = email, AdministratorLogin = login, AdministratorFIO = fio, AdministratorNumber = number, AdministratorPassword = password1 }))
|
||||
{
|
||||
Id = 1,
|
||||
CarBrand = "Brand1",
|
||||
CarModel = "Model1",
|
||||
CarCost = 50000.9,
|
||||
AdministratorId = 1
|
||||
});
|
||||
cars.Add(new CarSalesViewModel
|
||||
{
|
||||
Id = 2,
|
||||
CarBrand = "Brand2",
|
||||
CarModel = "Model2",
|
||||
CarCost = 100000.9,
|
||||
AdministratorId = 2
|
||||
});
|
||||
return View(cars);
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult IndexCarSales()
|
||||
{
|
||||
var cars = new List<CarSalesViewModel>();
|
||||
cars.Add(new CarSalesViewModel
|
||||
if (UserAdministrator.admin != null)
|
||||
{
|
||||
Id = 1,
|
||||
CarBrand = "Brand1",
|
||||
CarModel = "Model1",
|
||||
CarCost = 50000.9,
|
||||
AdministratorId = 1
|
||||
});
|
||||
cars.Add(new CarSalesViewModel
|
||||
{
|
||||
Id = 2,
|
||||
CarBrand = "Brand2",
|
||||
CarModel = "Model2",
|
||||
CarCost = 100000.9,
|
||||
AdministratorId = 2
|
||||
});
|
||||
return View(cars);
|
||||
var list = _data.GetCarSales(UserAdministrator.admin.Id);
|
||||
if (list != null)
|
||||
return View(list);
|
||||
return View(new List<CarSalesViewModel>());
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
public IActionResult CreateCarSales()
|
||||
[HttpPost]
|
||||
public void IndexCarSales(int id)
|
||||
{
|
||||
return View();
|
||||
if (UserAdministrator.admin != null)
|
||||
{
|
||||
_data.DeleteCarSale(id);
|
||||
}
|
||||
Response.Redirect("IndexCarSales");
|
||||
}
|
||||
public IActionResult IndexInspection()
|
||||
[HttpGet]
|
||||
public IActionResult CreateCarSales(int id)
|
||||
{
|
||||
List<InspectionViewModel> inspections = new List<InspectionViewModel>();
|
||||
inspections.Add(new InspectionViewModel
|
||||
if (id != 0)
|
||||
{
|
||||
Id = 1,
|
||||
InspectionName = "Inspection1",
|
||||
InspectionCost = 100.5,
|
||||
InspectionDate = DateTime.Now,
|
||||
AdministratorId = 1,
|
||||
EmployeeId = 1,
|
||||
InspectionCars = new()
|
||||
});
|
||||
inspections.Add(new InspectionViewModel
|
||||
{
|
||||
Id = 2,
|
||||
InspectionName = "Inspection2",
|
||||
InspectionCost = 1000.0,
|
||||
InspectionDate = DateTime.Now,
|
||||
AdministratorId = 2,
|
||||
EmployeeId = 2,
|
||||
InspectionCars = new()
|
||||
});
|
||||
return View(inspections);
|
||||
var value = _data.GetCarSale(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new CarSalesViewModel());
|
||||
}
|
||||
public IActionResult CreateInspection()
|
||||
[HttpPost]
|
||||
public IActionResult CreateCarSales(int id, string brand, string model, double cost)
|
||||
{
|
||||
var cars = new List<CarSalesViewModel>();
|
||||
cars.Add(new CarSalesViewModel
|
||||
CarSalesBindingModel models = new CarSalesBindingModel();
|
||||
models.Id = id;
|
||||
models.CarBrand = brand;
|
||||
models.CarModel = model;
|
||||
models.CarCost = cost;
|
||||
if (models.Id == 0)
|
||||
{
|
||||
Id = 1,
|
||||
CarBrand = "Brand1",
|
||||
CarModel = "Model1",
|
||||
CarCost = 50000.9,
|
||||
AdministratorId = 1
|
||||
});
|
||||
cars.Add(new CarSalesViewModel
|
||||
models.DateCreate = DateTime.Now;
|
||||
models.AdministratorId = UserAdministrator.admin!.Id;
|
||||
if (_data.CreateCarSale(models))
|
||||
return RedirectToAction("IndexCarSales");
|
||||
}
|
||||
else
|
||||
{
|
||||
Id = 2,
|
||||
CarBrand = "Brand2",
|
||||
CarModel = "Model2",
|
||||
CarCost = 100000.9,
|
||||
AdministratorId = 2
|
||||
});
|
||||
return View(cars);
|
||||
}
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (_data.UpdateCarSale(models))
|
||||
return RedirectToAction("IndexCarSales");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult IndexInspection()
|
||||
{
|
||||
if (IsLoggedIn)
|
||||
{
|
||||
var Inspections = _data.GetInspections(UserAdministrator.admin!.Id);
|
||||
return View(Inspections);
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult IndexInspection(int id)
|
||||
{
|
||||
_data.DeleteInspection(id);
|
||||
return RedirectToAction("IndexInspection");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateInspection(int id)
|
||||
{
|
||||
var CarSales = _data.GetCarSales(UserAdministrator.admin!.Id);
|
||||
ViewBag.AllCarSales = CarSales;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetInspection(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new InspectionViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateInspection(int id, string name, int[] CarSaleIds)
|
||||
{
|
||||
InspectionBindingModel model = new InspectionBindingModel();
|
||||
model.Id = id;
|
||||
model.InspectionName = name;
|
||||
model.AdministratorId = UserAdministrator.admin!.Id;
|
||||
var CarSales = _data.GetCarSales(UserAdministrator.admin!.Id);
|
||||
double sum = 0;
|
||||
for (int i = 0; i < CarSaleIds.Length; i++)
|
||||
{
|
||||
var CarSale = CarSales!.FirstOrDefault(x => x.Id == CarSaleIds[i])!;
|
||||
model.InspectionCars[CarSaleIds[i]] = (CarSale);
|
||||
sum += CarSale.CarCost;
|
||||
}
|
||||
if (model.InspectionCars.Count == 0)
|
||||
return RedirectToAction("IndexInspection");
|
||||
model.InspectionCost = sum;
|
||||
if (id != 0)
|
||||
{
|
||||
_data.UpdateInspection(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_data.CreateInspection(model);
|
||||
}
|
||||
return RedirectToAction("IndexInspection");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult IndexCompletions()
|
||||
{
|
||||
if (UserAdministrator.admin != null)
|
||||
{
|
||||
var Completionss = _data.GetCompletionss(UserAdministrator.admin.Id);
|
||||
return View(Completionss);
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult IndexCompletions(int id)
|
||||
{
|
||||
_data.DeleteCompletions(id);
|
||||
return RedirectToAction("IndexCompletions");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateCompletions(int id)
|
||||
{
|
||||
var CarSales = _data.GetCarSales(UserAdministrator.admin!.Id);
|
||||
ViewBag.AllCarSales = CarSales;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetCompletions(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new CompletionsViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateCompletions(int id, string name, string features, int[] CarSaleIds)
|
||||
{
|
||||
CompletionsBindingModel model = new CompletionsBindingModel();
|
||||
model.Id = id;
|
||||
model.СompletionName = name;
|
||||
model.СompletionFeatures = features;
|
||||
model.AdministratorId = UserAdministrator.admin!.Id;
|
||||
var CarSales = _data.GetCarSales(UserAdministrator.admin!.Id);
|
||||
double sum = 0;
|
||||
for (int i = 0; i < CarSaleIds.Length; i++)
|
||||
{
|
||||
var CarSale = CarSales!.FirstOrDefault(x => x.Id == CarSaleIds[i])!;
|
||||
model.СompletionCars[CarSaleIds[i]] = CarSale;
|
||||
sum += CarSale.CarCost;
|
||||
}
|
||||
model.СompletionPrice = sum;
|
||||
bool changed = false;
|
||||
if (model.СompletionCars.Count > 0)
|
||||
{
|
||||
if (id != 0)
|
||||
{
|
||||
changed = _data.UpdateCompletions(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = _data.CreateCompletions(model);
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
return RedirectToAction("IndexCompletions");
|
||||
else
|
||||
{
|
||||
ViewBag.AllCarSales = CarSales;
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (IsLoggedIn)
|
||||
return View(UserAdministrator.admin);
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Privacy(int id, string login, string email, string password, string fio, string number)
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
AdministratorBindingModel user = new() { Id = id, AdministratorLogin = login, AdministratorEmail = email, AdministratorPassword = password, AdministratorFIO = fio, AdministratorNumber = number };
|
||||
if (_data.UpdateUser(user))
|
||||
{
|
||||
UserAdministrator.admin = new AdministratorViewModel { Id = id, AdministratorLogin = login, AdministratorPassword = password, AdministratorFIO = fio, AdministratorEmail = email, AdministratorNumber = number };
|
||||
}
|
||||
return View(user);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CarSaleTimeChoose()
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult SendReport(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
|
||||
|
||||
HttpContext.Session.SetString("StartDate", startDate.ToString());
|
||||
HttpContext.Session.SetString("EndDate", endDate.ToString());
|
||||
|
||||
return RedirectToAction("CarSaleTimeReport");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CarSaleTimeReport()
|
||||
{
|
||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
||||
var startDate = DateTime.Parse(startDateStr);
|
||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
||||
|
||||
var values = _data.GetTimeReport(startDate, endDate, AdminId);
|
||||
|
||||
ViewBag.StartDate = startDate;
|
||||
ViewBag.EndDate = endDate;
|
||||
|
||||
return View(values);
|
||||
}
|
||||
public IActionResult CarsPreSaleWorkReport()
|
||||
{
|
||||
List<CarsPreSaleWorkReportViewModel> CarSalePreSaleWorkReports = new List<CarsPreSaleWorkReportViewModel>
|
||||
{
|
||||
new CarsPreSaleWorkReportViewModel
|
||||
{
|
||||
CarBrand = "бэха",
|
||||
PreSaleWork = new List<string> { "Цех 1", "Цех 2" }
|
||||
},
|
||||
new CarsPreSaleWorkReportViewModel
|
||||
{
|
||||
CarBrand = "мерс",
|
||||
PreSaleWork = new List<string> { "Цех 3", "Цех 4" }
|
||||
}
|
||||
};
|
||||
return View(CarSalePreSaleWorkReports);
|
||||
}
|
||||
public IActionResult ReportsMenu()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult CarsPreSaleWorkReport()
|
||||
[HttpGet]
|
||||
public IActionResult InspectionEmployeeAdd(int id)
|
||||
{
|
||||
List<CarsPreSaleWorkReportViewModel> CarsPreSaleWork = new List<CarsPreSaleWorkReportViewModel>
|
||||
{
|
||||
new CarsPreSaleWorkReportViewModel
|
||||
{
|
||||
CarBrand = "CarBrand1",
|
||||
PreSaleWork = new List<string> { "PreSaleWork1", "PreSaleWork2" },
|
||||
},
|
||||
new CarsPreSaleWorkReportViewModel
|
||||
{
|
||||
CarBrand = "CarBrand2",
|
||||
PreSaleWork = new List<string> { "PreSaleWork3", "PreSaleWork4" },
|
||||
}
|
||||
};
|
||||
return View(CarsPreSaleWork);
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
var Inspection = _data.GetInspection(id);
|
||||
ViewBag.Inspection = Inspection;
|
||||
var Employees = _data.GetEmployees();
|
||||
return View(Employees);
|
||||
}
|
||||
public IActionResult CarsPeriodReport()
|
||||
[HttpPost]
|
||||
public IActionResult InspectionEmployeeAdd(int InspectionId, int EmployeeId)
|
||||
{
|
||||
List<CarsPeriodReportViewModel> CarsPeriod = new List<CarsPeriodReportViewModel>
|
||||
{
|
||||
new CarsPeriodReportViewModel
|
||||
{
|
||||
CarBrand = "CarBrand1",
|
||||
Completions = new List<string> { "Completions1", "Completions2" },
|
||||
Employees = new List<string> { "Employees1", "Employees2" },
|
||||
},
|
||||
new CarsPeriodReportViewModel
|
||||
{
|
||||
CarBrand = "CarBrand2",
|
||||
Completions = new List<string> { "Completions3", "Completions4" },
|
||||
Employees = new List<string> { "Employees3", "Employees4" },
|
||||
}
|
||||
};
|
||||
return View(CarsPeriod);
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
var Inspection = _data.GetInspection(InspectionId);
|
||||
if (Inspection == null)
|
||||
return RedirectToAction("Index");
|
||||
InspectionBindingModel InspectionBinding = new() { Id = InspectionId, InspectionCost = Inspection.InspectionCost, InspectionName = Inspection.InspectionName, AdministratorId = Inspection.AdministratorId, InspectionCars = Inspection.InspectionCars, EmployeeId = EmployeeId };
|
||||
_data.UpdateInspection(InspectionBinding);
|
||||
return RedirectToAction("IndexInspection");
|
||||
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace CarCenterAdministratorAPP.Models
|
||||
namespace AdministratorApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
|
@ -1,15 +1,42 @@
|
||||
using CarCenterBusinessLogic.BusinessLogics;
|
||||
using CarCenterContracts.BusinessLogicsContracts;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterDataBaseImplement.Implements;
|
||||
using CarCenterDataBaseImplement.Implemets;
|
||||
using AdministratorApp;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
|
||||
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
builder.Services.AddTransient<IAdministratorStorage, AdministratorStorage>();
|
||||
builder.Services.AddTransient<ICarSalesStorage, CarStorage>();
|
||||
builder.Services.AddTransient<IInspectionStorage, InspectionStorage>();
|
||||
builder.Services.AddTransient<ICompletionsStorage, CompletionsStorage>();
|
||||
builder.Services.AddTransient<IEmployeeStorage, EmployeeStorage>();
|
||||
builder.Services.AddTransient<IAdministratorLogic, AdministratorLogic>();
|
||||
builder.Services.AddTransient<ICarSalesLogic, CarSalesLogic>();
|
||||
builder.Services.AddTransient<IInspectionLogic, InspectionLogic>();
|
||||
builder.Services.AddTransient<ICompletionsLogic, CompletionsLogic>();
|
||||
builder.Services.AddTransient<IEmployeeLogic, EmployeeLogic>();
|
||||
builder.Services.AddTransient<AdministratorData>();
|
||||
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromMinutes(30);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
@ -17,11 +44,11 @@ app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseSession();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
9
CarCenter/CarCenterAdministratorAPP/UserAdministrator.cs
Normal file
9
CarCenter/CarCenterAdministratorAPP/UserAdministrator.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using CarCenterContracts.ViewModels;
|
||||
|
||||
namespace AdministratorApp
|
||||
{
|
||||
public static class UserAdministrator
|
||||
{
|
||||
public static AdministratorViewModel? admin { get; set; }
|
||||
}
|
||||
}
|
@ -37,12 +37,7 @@
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
@foreach (var employee in cars.Employees)
|
||||
{
|
||||
<li>@employee</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
@ -1,24 +1,70 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateCarSales";
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@{
|
||||
ViewData["Title"] = "CreateCar";
|
||||
}
|
||||
@model CarSalesViewModel;
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание продаваемой машины</h2>
|
||||
<h2 class="display-4">Продаваемая машина</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Производитель:</div>
|
||||
<div class="col-8"><input type="text" name="carbrand" id="carbrand" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Модель:</div>
|
||||
<div class="col-8"><input type="text" name="carmodel" id="carmodel" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Стоимость:</div>
|
||||
<div class="col-8"><input type="text" name="carcost" id="carcost" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<form id="CarForm" method="post">
|
||||
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden" />
|
||||
<div class="row">
|
||||
<div class="col-4">Бренд машины:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="brand" id="brand" value="@Model.CarBrand" />
|
||||
<span id="nameError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Модель машины:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="model" id="model" value="@Model.CarModel" />
|
||||
<span id="nameError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Стоимость:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="cost" id="cost" value="@Model.CarCost" />
|
||||
<span id="costError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#CarForm').submit(function (event) {
|
||||
var brand = $('#brand').val();
|
||||
var model = $('#model').val();
|
||||
var cost = $('#cost').val();
|
||||
var isValid = true;
|
||||
|
||||
$('#brandError').text('');
|
||||
$('#modelError').text('');
|
||||
$('#costError').text('');
|
||||
|
||||
if (brand.length < 2 || brand.length > 50) {
|
||||
$('#nameError').text('Название должно быть от 2 до 50 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
if (model.length < 2 || model.length > 50) {
|
||||
$('#modelError').text('Название должно быть от 2 до 50 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isNaN(cost) || cost <= 0) {
|
||||
$('#costError').text('Цена должна быть положительным числом.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -1,41 +1,70 @@
|
||||
@using CarCenterContracts.ViewModels
|
||||
|
||||
@model List<CarSalesViewModel>
|
||||
@model CompletionsViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreateCompletions";
|
||||
ViewData["Title"] = "CreateProduction";
|
||||
ViewBag.Cars = Model.СompletionCars;
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание изделия</h2>
|
||||
<h2 class="display-4">Создание комплектации</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<form id="productionForm" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="title" id="title" /></div>
|
||||
<div class="col-4">Название комплектации:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" value="@Model.СompletionName" />
|
||||
<span id="titleError" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-4">Особенности комплектации:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="features" id="features" value="@Model.СompletionFeatures" />
|
||||
<span id="titleError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Completions</div>
|
||||
<div>Машины</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="carsTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Выбор</th>
|
||||
<th>Название</th>
|
||||
<th>Бренд</th>
|
||||
<th>Модель</th>
|
||||
<th>Стоимость</th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var cars in Model)
|
||||
@foreach (var car in ViewBag.cars)
|
||||
{
|
||||
<tr>
|
||||
<tr data-car-id="@car.Value.Id">
|
||||
<td>
|
||||
<input type="checkbox" name="cars" value="@cars.Id" />
|
||||
<input type="hidden" name="carIds" value="@car.Value.Id" />
|
||||
@car.Value.CarBrand
|
||||
</td>
|
||||
<td>@cars.CarBrand</td>
|
||||
<td>
|
||||
<input type="hidden" name="carIds" value="@car.Value.Id" />
|
||||
@car.Value.CarModel
|
||||
</td>
|
||||
<td class="car-cost" data-cost="@car.Value.CarCost">@car.Value.CarCost</td>
|
||||
<td><button type="button" class="deletecar" data-car-id="@car.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="carSelect" class="form-control">
|
||||
<option value="">Выберите машину</option>
|
||||
@foreach (var car in ViewBag.AllCarSales)
|
||||
{
|
||||
<option value="@car.Id" data-cost="@car.CarCost">@car.CarBrand</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addcar" class="btn btn-secondary">Добавить машину</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
|
@ -61,7 +61,10 @@
|
||||
<a asp-action="CreateCarSales" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">Удалить</a>
|
||||
<form method="post">
|
||||
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
||||
<input type="submit" class="btn btn-danger" value="Удалить" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<div class="list-group">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</div>
|
||||
</div>
|
@ -1,6 +1,119 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
</div>
|
||||
<form id="adminForm" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Имя:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="name" id="name" />
|
||||
<span id="nameError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login" id="login" />
|
||||
<span id="loginError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Почта:</div>
|
||||
<div class="col-8">
|
||||
<input type="email" name="email" id="email" />
|
||||
<span id="emailError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Номер телефона:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="number" id="number" />
|
||||
<span id="numberError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password1" id="password1" />
|
||||
<span id="password1Error" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Повтор пароля:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password2" id="password2" />
|
||||
<span id="password2Error" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#adminForm').submit(function (event) {
|
||||
var name = $('#name').val();
|
||||
var login = $('#login').val();
|
||||
var email = $('#email').val();
|
||||
var number = $('#number').val();
|
||||
var password1 = $('#password1').val();
|
||||
var password2 = $('#password2').val();
|
||||
var isValid = true;
|
||||
|
||||
$('#nameError').text('');
|
||||
$('#loginError').text('');
|
||||
$('#emailError').text('');
|
||||
$('#numberError').text('');
|
||||
$('#password1Error').text('');
|
||||
$('#password2Error').text('');
|
||||
|
||||
// Валидация имени
|
||||
if (name.length < 2 || name.length > 20) {
|
||||
$('#nameError').text('Имя должно быть от 2 до 20 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация логина
|
||||
if (login.length < 5 || login.length > 50) {
|
||||
$('#loginError').text('Логин должен быть от 5 до 50 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация почты
|
||||
var emailPattern = /^[a-zA-Z0-9._-]+@@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||||
if (!emailPattern.test(email)) {
|
||||
$('#emailError').text('Неверный формат почты.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация номера телефона
|
||||
var numberPattern = /^\d{11}$/;
|
||||
if (!numberPattern.test(number)) {
|
||||
$('#numberError').text('Неверный формат номера телефона.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация пароля
|
||||
if (password1.length < 8 || password1.length > 20) {
|
||||
$('#password1Error').text('Пароль должен быть от 8 до 20 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Проверка совпадения паролей
|
||||
if (password1 !== password2) {
|
||||
$('#password2Error').text('Пароли не совпадают.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -1,29 +1,119 @@
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8"><input type="text" name="name" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8"><input type="text" name="login" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Почта:</div>
|
||||
<div class="col-8"><input type="email" name="email" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<form id="registerForm" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="fio" id="fio" />
|
||||
<span id="nameError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login" id="login" />
|
||||
<span id="loginError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Почта:</div>
|
||||
<div class="col-8">
|
||||
<input type="email" name="email" id="email" />
|
||||
<span id="emailError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Номер телефона:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="number" id="number" />
|
||||
<span id="numberError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password1" id="password1" />
|
||||
<span id="password1Error" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Повтор пароля:</div>
|
||||
<div class="col-8">
|
||||
<input type="password" name="password2" id="password2" />
|
||||
<span id="password2Error" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#registerForm').submit(function (event) {
|
||||
var fio = $('#fio').val();
|
||||
var login = $('#login').val();
|
||||
var email = $('#email').val();
|
||||
var number = $('#number').val();
|
||||
var password1 = $('#password1').val();
|
||||
var password2 = $('#password2').val();
|
||||
var isValid = true;
|
||||
|
||||
$('#fioError').text('');
|
||||
$('#loginError').text('');
|
||||
$('#emailError').text('');
|
||||
$('#numberError').text('');
|
||||
$('#password1Error').text('');
|
||||
$('#password2Error').text('');
|
||||
|
||||
// Валидация имени
|
||||
if (fio.length < 2 || fio.length > 30) {
|
||||
$('#fioError').text('ФИО должно быть от 2 до 30 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация логина
|
||||
if (login.length < 5 || login.length > 50) {
|
||||
$('#loginError').text('Логин должен быть от 5 до 50 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация почты
|
||||
var emailPattern = /^[a-zA-Z0-9._-]+@@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||||
if (!emailPattern.test(email)) {
|
||||
$('#emailError').text('Неверный формат почты.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация номера телефона
|
||||
var numberPattern = /^\d{11}$/;
|
||||
if (!numberPattern.test(number)) {
|
||||
$('#numberError').text('Неверный формат номера телефона.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Валидация пароля
|
||||
if (password1.length < 8 || password1.length > 20) {
|
||||
$('#password1Error').text('Пароль должен быть от 8 до 20 символов.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
// Проверка совпадения паролей
|
||||
if (password1 !== password2) {
|
||||
$('#password2Error').text('Пароли не совпадают.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -1,4 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
@{
|
||||
ViewData["Login"] = UserAdministrator.admin == null ? "Пользователь" : UserAdministrator.admin.AdministratorLogin;
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
@ -12,7 +15,9 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Администратор Автоцентр "Корыто"</a>
|
||||
<a class="navbar-brand" asp-controller="Home" asp-action="Index">Администратор Автоцентр "Корыто"</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Login"]</a>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
@ -1,3 +1,3 @@
|
||||
@using CarCenterAdministratorAPP
|
||||
@using CarCenterAdministratorAPP.Models
|
||||
@using AdministratorApp
|
||||
@using AdministratorApp.Models
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
16
CarCenter/CarCenterAdministratorAPP/log4net.config
Normal file
16
CarCenter/CarCenterAdministratorAPP/log4net.config
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<log4net>
|
||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="c:/temp/GoWorkCourse.log" />
|
||||
<appendToFile value="true" />
|
||||
<maximumFileSize value="100KB" />
|
||||
<maxSizeRollBackups value="2" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="TRACE" />
|
||||
<appender-ref ref="RollingFile" />
|
||||
</root>
|
||||
</log4net>
|
@ -53,7 +53,7 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public AdministratorViewModel? ReadElement(AdministratorSearchModel model)
|
||||
public AdministratorViewModel? ReadElement(AdministratorSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
|
@ -13,13 +13,11 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
private readonly IManagerLogic _managerLogic;
|
||||
|
||||
public EmployeeLogic(ILogger<EmployeeLogic> logger, IEmployeeStorage EmployeeStorage, IManagerLogic ManagerLogic)
|
||||
public EmployeeLogic(ILogger<EmployeeLogic> logger, IEmployeeStorage EmployeeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_employeeStorage = EmployeeStorage;
|
||||
_managerLogic = ManagerLogic;
|
||||
}
|
||||
public bool Create(EmployeeBindingModel model)
|
||||
{
|
||||
|
@ -10,6 +10,6 @@ namespace CarCenterContracts.ViewModels
|
||||
{
|
||||
public string CarBrand { get; set; } = string.Empty;
|
||||
public List<string> Completions { get; set; } = new();
|
||||
public List<string> Employees { get; set; } = new();
|
||||
public List<string> Inspections { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace CarCenterDataBaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D5A5OOG\GOLDFEST;Initial Catalog=CarCenter;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D5A5OOG\GOLDFEST;Initial Catalog=CarCenter2;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
@ -6,6 +6,7 @@ using CarCenterDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -14,114 +15,65 @@ namespace CarCenterDataBaseImplement.Implements
|
||||
{
|
||||
public class AdministratorStorage : IAdministratorStorage
|
||||
{
|
||||
public List<AdministratorViewModel> GetFullList()
|
||||
public AdministratorViewModel? Delete(AdministratorBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDataBase();
|
||||
|
||||
return context.Administrators
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<AdministratorViewModel> GetFilteredList(AdministratorSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.AdministratorFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new CarCenterDataBase();
|
||||
|
||||
return context.Administrators
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Equipments)
|
||||
.Where(x => x.AdministratorLogin.Contains(model.AdministratorLogin) && x.AdministratorPassword == model.AdministratorPassword)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
var newAdministrator = context.Administrators.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (newAdministrator == null)
|
||||
return null;
|
||||
context.Administrators.Remove(newAdministrator);
|
||||
context.SaveChanges();
|
||||
return newAdministrator.GetViewModel;
|
||||
}
|
||||
|
||||
public AdministratorViewModel? GetElement(AdministratorSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.AdministratorLogin)) { return null; }
|
||||
using var context = new CarCenterDataBase();
|
||||
return context.Administrators.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.AdministratorLogin) && !string.IsNullOrEmpty(model.AdministratorPassword) && x.AdministratorLogin.Equals(model.AdministratorLogin) && x.AdministratorPassword.Equals(model.AdministratorPassword)))?.GetViewModel; ;
|
||||
}
|
||||
|
||||
public List<AdministratorViewModel> GetFilteredList(AdministratorSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.AdministratorLogin))
|
||||
return new();
|
||||
using var context = new CarCenterDataBase();
|
||||
if (model.Id.HasValue)
|
||||
return context.Administrators
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Equipments)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?
|
||||
.GetViewModel;
|
||||
{
|
||||
return context.Administrators.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Administrators.Where(x => x.AdministratorLogin.Equals(model.AdministratorLogin)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.AdministratorEmail) && !string.IsNullOrEmpty(model.AdministratorPassword))
|
||||
return context.Administrators
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Equipments)
|
||||
.FirstOrDefault(x => x.AdministratorEmail.Equals(model.AdministratorEmail) && x.AdministratorPassword.Equals(model.AdministratorPassword))?
|
||||
.GetViewModel;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.AdministratorEmail))
|
||||
return context.Administrators
|
||||
.Include(x => x.Inspections)
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Equipments)
|
||||
.FirstOrDefault(x => x.AdministratorEmail.Equals(model.AdministratorEmail))?
|
||||
.GetViewModel;
|
||||
|
||||
return null;
|
||||
public List<AdministratorViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDataBase();
|
||||
return context.Administrators.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public AdministratorViewModel? Insert(AdministratorBindingModel model)
|
||||
{
|
||||
var newAdministrator = Administrator.Create(model);
|
||||
|
||||
if (newAdministrator == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CarCenterDataBase();
|
||||
|
||||
var newAdministrator = Administrator.Create(model);
|
||||
if (newAdministrator == null)
|
||||
return null;
|
||||
context.Administrators.Add(newAdministrator);
|
||||
context.SaveChanges();
|
||||
|
||||
return newAdministrator.GetViewModel;
|
||||
}
|
||||
|
||||
public AdministratorViewModel? Update(AdministratorBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDataBase();
|
||||
|
||||
var administrator = context.Administrators
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (administrator == null)
|
||||
{
|
||||
var newAdministrator = context.Administrators.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (newAdministrator == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
administrator.Update(model);
|
||||
newAdministrator.Update(model);
|
||||
context.SaveChanges();
|
||||
|
||||
return administrator.GetViewModel;
|
||||
}
|
||||
|
||||
public AdministratorViewModel? Delete(AdministratorBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDataBase();
|
||||
|
||||
var element = context.Administrators.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Administrators.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
return newAdministrator.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace CarCenterDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDataBase))]
|
||||
[Migration("20240527163409_InitialCreate")]
|
||||
[Migration("20240527184458_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
Loading…
x
Reference in New Issue
Block a user