just end?
This commit is contained in:
parent
588f856ce8
commit
80f3f77d0d
@ -23,7 +23,10 @@ namespace DatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login)) { return null; }
|
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login)) { return null; }
|
||||||
using var context = new FactoryGoWorkDatabase();
|
using var context = new FactoryGoWorkDatabase();
|
||||||
return context.Guarantors.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && x.Login.Equals(model.Login) && x.Password.Equals(model.Password)))?.GetViewModel; ;
|
if (!string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))
|
||||||
|
return context.Guarantors.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||||
|
else
|
||||||
|
return context.Guarantors.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && x.Login.Equals(model.Login) && x.Password.Equals(model.Password)))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model)
|
public List<GuarantorViewModel> GetFilteredList(GuarantorSearchModel model)
|
||||||
|
@ -34,7 +34,7 @@ namespace DatabaseImplement.Models
|
|||||||
public virtual List<DetailProduction> Details { get; set; } = new();
|
public virtual List<DetailProduction> Details { get; set; } = new();
|
||||||
public virtual Implementer User { get; set; }
|
public virtual Implementer User { get; set; }
|
||||||
[ForeignKey("ProductionId")]
|
[ForeignKey("ProductionId")]
|
||||||
public virtual List<Workshop> Workshops { get; set; }
|
public virtual List<Workshop> Workshops { get; set; } = new();
|
||||||
|
|
||||||
public static Production Create(FactoryGoWorkDatabase context, ProductionBindingModel model)
|
public static Production Create(FactoryGoWorkDatabase context, ProductionBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Contracts.BindingModels;
|
using Contracts.BindingModels;
|
||||||
using Contracts.BusinessLogicsContracts;
|
using Contracts.BusinessLogicsContracts;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
using GuarantorAPP.Models;
|
using GuarantorAPP.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -19,6 +20,22 @@ namespace GuarantorAPP.Controllers
|
|||||||
}
|
}
|
||||||
private bool IsLoggedIn { get { return UserGuarantor.user != null; } }
|
private bool IsLoggedIn { get { return UserGuarantor.user != null; } }
|
||||||
private int UserId { get { return UserGuarantor.user!.Id; } }
|
private int UserId { get { return UserGuarantor.user!.Id; } }
|
||||||
|
[HttpPost]
|
||||||
|
public JsonResult CheckLogin(string login)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var unique = _data.CheckLogin(login);
|
||||||
|
return Json(new
|
||||||
|
{
|
||||||
|
isUnique = unique
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return Json(new {isUnique = false});
|
||||||
|
}
|
||||||
|
}
|
||||||
public IActionResult IndexNonReg()
|
public IActionResult IndexNonReg()
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
if (!IsLoggedIn)
|
||||||
@ -41,11 +58,18 @@ namespace GuarantorAPP.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void Enter(string login, string password)
|
public void Enter(string login, string password)
|
||||||
{
|
{
|
||||||
var user = _data.Login(login, password);
|
try
|
||||||
if (user != null)
|
|
||||||
{
|
{
|
||||||
UserGuarantor.user = user;
|
var user = _data.Login(login, password);
|
||||||
Response.Redirect("Index");
|
if (user != null)
|
||||||
|
{
|
||||||
|
UserGuarantor.user = user;
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
Response.Redirect("Enter");
|
||||||
|
} catch (Exception)
|
||||||
|
{
|
||||||
|
Response.Redirect("IndexNonReg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -61,91 +85,126 @@ namespace GuarantorAPP.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void Register(string name, string login, string email, string password1, string password2)
|
public void Register(string name, string login, string email, string password1, string password2)
|
||||||
{
|
{
|
||||||
if (password1 == password2 && _data.Register(new() { Email = email, Login = login, Name = name, Password = password1 }))
|
try
|
||||||
{
|
{
|
||||||
Response.Redirect("Index");
|
if (password1 == password2 && _data.Register(new() { Email = email, Login = login, Name = name, Password = password1 }))
|
||||||
|
{
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
} catch (Exception)
|
||||||
|
{
|
||||||
|
Response.Redirect("IndexNonReg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult IndexMachine()
|
public IActionResult IndexMachine()
|
||||||
{
|
{
|
||||||
if (UserGuarantor.user != null)
|
if (!IsLoggedIn)
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var machines = _data.GetMachines(UserGuarantor.user.Id);
|
var machines = _data.GetMachines(UserGuarantor.user!.Id);
|
||||||
return View(machines);
|
return View(machines);
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
}
|
}
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult IndexMachine(int id)
|
public IActionResult IndexMachine(int id)
|
||||||
{
|
{
|
||||||
_data.DeleteMachine(id);
|
try
|
||||||
return RedirectToAction("IndexMachine");
|
{
|
||||||
|
_data.DeleteMachine(id);
|
||||||
|
return RedirectToAction("IndexMachine");
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateMachine(int id)
|
public IActionResult CreateMachine(int id)
|
||||||
{
|
{
|
||||||
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
if (!IsLoggedIn)
|
||||||
ViewBag.AllWorkers = workers;
|
return RedirectToAction("IndexNonReg");
|
||||||
if (id != 0)
|
try
|
||||||
{
|
{
|
||||||
var value = _data.GetMachine(id);
|
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
||||||
if (value != null)
|
ViewBag.AllWorkers = workers;
|
||||||
return View(value);
|
if (id != 0)
|
||||||
|
{
|
||||||
|
var value = _data.GetMachine(id);
|
||||||
|
if (value != null)
|
||||||
|
return View(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return View(new MachineViewModel());
|
catch
|
||||||
}
|
{
|
||||||
|
return RedirectToAction("IndexMachine");
|
||||||
|
}
|
||||||
|
return View(new MachineViewModel());
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult CreateMachine(int id, string title, string country, int[] workerIds)
|
public IActionResult CreateMachine(int id, string title, string country, int[] workerIds)
|
||||||
{
|
{
|
||||||
MachineBindingModel model = new MachineBindingModel();
|
try
|
||||||
model.Id = id;
|
|
||||||
model.Title = title;
|
|
||||||
model.Country = country;
|
|
||||||
model.DateCreate = DateTime.Now;
|
|
||||||
model.UserId = UserGuarantor.user!.Id;
|
|
||||||
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
|
||||||
for (int i = 0; i < workerIds.Length; i++)
|
|
||||||
{
|
{
|
||||||
var worker = workers!.FirstOrDefault(x => x.Id == workerIds[i]);
|
MachineBindingModel model = new MachineBindingModel();
|
||||||
model.MachineWorker[workerIds[i]] = worker;
|
model.Id = id;
|
||||||
}
|
model.Title = title;
|
||||||
bool changed = false;
|
model.Country = country;
|
||||||
if (model.MachineWorker.Count > 0)
|
model.DateCreate = DateTime.Now;
|
||||||
{
|
model.UserId = UserGuarantor.user!.Id;
|
||||||
if (id != 0)
|
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
||||||
|
for (int i = 0; i < workerIds.Length; i++)
|
||||||
{
|
{
|
||||||
changed = _data.UpdateMachine(model);
|
var worker = workers!.FirstOrDefault(x => x.Id == workerIds[i]);
|
||||||
|
model.MachineWorker[workerIds[i]] = worker;
|
||||||
}
|
}
|
||||||
|
bool changed = false;
|
||||||
|
if (model.MachineWorker.Count > 0)
|
||||||
|
{
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
changed = _data.UpdateMachine(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changed = _data.CreateMachine(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
return RedirectToAction("IndexMachine");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
changed = _data.CreateMachine(model);
|
ViewBag.AllWorkers = workers;
|
||||||
|
return View(model);
|
||||||
}
|
}
|
||||||
}
|
} catch
|
||||||
if (changed)
|
|
||||||
return RedirectToAction("IndexMachine");
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ViewBag.AllWorkers = workers;
|
return RedirectToAction("IndexMachine");
|
||||||
return View(model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult IndexWorker()
|
public IActionResult IndexWorker()
|
||||||
{
|
{
|
||||||
if (UserGuarantor.user != null)
|
if (!IsLoggedIn)
|
||||||
{
|
return RedirectToAction("IndexNonReg");
|
||||||
var list = _data.GetWorkers(UserGuarantor.user.Id);
|
try {
|
||||||
|
var list = _data.GetWorkers(UserGuarantor.user!.Id);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
return View(list);
|
return View(list);
|
||||||
return View(new List<WorkerViewModel>());
|
|
||||||
}
|
}
|
||||||
return RedirectToAction("IndexNonReg");
|
catch (Exception)
|
||||||
}
|
{
|
||||||
|
return View(new List<WorkerViewModel>()); ;
|
||||||
|
}
|
||||||
|
return View(new List<WorkerViewModel>());
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void IndexWorker(int id)
|
public void IndexWorker(int id)
|
||||||
{
|
{
|
||||||
if (UserGuarantor.user != null)
|
if (IsLoggedIn)
|
||||||
{
|
{
|
||||||
_data.DeleteWorker(id);
|
_data.DeleteWorker(id);
|
||||||
}
|
}
|
||||||
@ -154,6 +213,10 @@ namespace GuarantorAPP.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateWorker(int id)
|
public IActionResult CreateWorker(int id)
|
||||||
{
|
{
|
||||||
|
if (!IsLoggedIn)
|
||||||
|
{
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
}
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
var value = _data.GetWorker(id);
|
var value = _data.GetWorker(id);
|
||||||
@ -165,83 +228,105 @@ namespace GuarantorAPP.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult CreateWorker(WorkerBindingModel model)
|
public IActionResult CreateWorker(WorkerBindingModel model)
|
||||||
{
|
{
|
||||||
if (model.Id == 0)
|
try
|
||||||
{
|
{
|
||||||
model.UserId = UserGuarantor.user!.Id;
|
if (model.Id == 0)
|
||||||
if (_data.CreateWorker(model))
|
{
|
||||||
return RedirectToAction("IndexWorker");
|
model.UserId = UserId;
|
||||||
|
if (_data.CreateWorker(model))
|
||||||
|
return RedirectToAction("IndexWorker");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_data.UpdateWorker(model))
|
||||||
|
return RedirectToAction("IndexWorker");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception)
|
||||||
{
|
{
|
||||||
if (_data.UpdateWorker(model))
|
return RedirectToAction("IndexWorker");
|
||||||
return RedirectToAction("IndexWorker");
|
|
||||||
}
|
}
|
||||||
return View();
|
return RedirectToAction("IndexWorker");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult IndexWorkshop()
|
public IActionResult IndexWorkshop()
|
||||||
{
|
{
|
||||||
if (IsLoggedIn)
|
if (IsLoggedIn)
|
||||||
{
|
{
|
||||||
var workshops = _data.GetWorkshops(UserGuarantor.user!.Id);
|
try
|
||||||
return View(workshops);
|
{
|
||||||
|
var workshops = _data.GetWorkshops(UserGuarantor.user!.Id);
|
||||||
|
return View(workshops);
|
||||||
|
} catch (Exception)
|
||||||
|
{
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return RedirectToAction("IndexNonReg");
|
return RedirectToAction("IndexNonReg");
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult IndexWorkshop(int id)
|
public IActionResult IndexWorkshop(int id)
|
||||||
{
|
{
|
||||||
_data.DeleteWorkshop(id);
|
try
|
||||||
|
{
|
||||||
|
_data.DeleteWorkshop(id);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
return RedirectToAction("IndexWorkshop");
|
return RedirectToAction("IndexWorkshop");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateWorkshop(int id)
|
public IActionResult CreateWorkshop(int id)
|
||||||
{
|
{
|
||||||
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
if (!IsLoggedIn)
|
||||||
ViewBag.AllWorkers = workers;
|
return RedirectToAction("IndexNonReg");
|
||||||
if (id != 0)
|
try
|
||||||
{
|
{
|
||||||
var value = _data.GetWorkshop(id);
|
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
||||||
if (value != null)
|
ViewBag.AllWorkers = workers;
|
||||||
return View(value);
|
if (id != 0)
|
||||||
|
{
|
||||||
|
var value = _data.GetWorkshop(id);
|
||||||
|
if (value != null)
|
||||||
|
return View(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception) { }
|
||||||
return View(new WorkshopViewModel());
|
return View(new WorkshopViewModel());
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult CreateWorkshop(int id, string title, string address, string director, int[] workerIds)
|
public IActionResult CreateWorkshop(int id, string title, string address, string director, int[] workerIds)
|
||||||
{
|
{
|
||||||
WorkshopBindingModel model = new WorkshopBindingModel();
|
try
|
||||||
model.Id = id;
|
|
||||||
model.Title = title;
|
|
||||||
model.Address = address;
|
|
||||||
model.Director = director;
|
|
||||||
model.DateCreate = DateTime.Now;
|
|
||||||
model.UserId = UserGuarantor.user!.Id;
|
|
||||||
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
|
||||||
for (int i = 0; i < workerIds.Length; i++)
|
|
||||||
{
|
|
||||||
var worker = workers!.FirstOrDefault(x => x.Id == workerIds[i])!;
|
|
||||||
model.WorkshopWorker[workerIds[i]] = (worker);
|
|
||||||
}
|
|
||||||
bool changed = false;
|
|
||||||
if (model.WorkshopWorker.Count > 0)
|
|
||||||
{
|
{
|
||||||
|
WorkshopBindingModel model = new WorkshopBindingModel();
|
||||||
|
model.Id = id;
|
||||||
|
model.Title = title;
|
||||||
|
model.Address = address;
|
||||||
|
model.Director = director;
|
||||||
|
model.DateCreate = DateTime.Now;
|
||||||
|
model.UserId = UserGuarantor.user!.Id;
|
||||||
|
var workers = _data.GetWorkers(UserGuarantor.user!.Id);
|
||||||
|
for (int i = 0; i < workerIds.Length; i++)
|
||||||
|
{
|
||||||
|
var worker = workers!.FirstOrDefault(x => x.Id == workerIds[i])!;
|
||||||
|
model.WorkshopWorker[workerIds[i]] = (worker);
|
||||||
|
}
|
||||||
|
if (model.WorkshopWorker.Count == 0)
|
||||||
|
return RedirectToAction("IndexWorkshop");
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
changed = _data.UpdateWorkshop(model);
|
_data.UpdateWorkshop(model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
changed = _data.CreateWorkshop(model);
|
_data.CreateWorkshop(model);
|
||||||
}
|
}
|
||||||
}
|
} catch (InvalidOperationException ex)
|
||||||
if (changed)
|
|
||||||
return RedirectToAction("IndexWorkshop");
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ViewBag.AllWorkers = workers;
|
ViewBag.ErrorMessage = "Такое название Цеха уже сущетсвует";
|
||||||
return View(model);
|
return View();
|
||||||
}
|
}
|
||||||
|
return RedirectToAction("IndexWorkshop");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Privacy()
|
public IActionResult Privacy()
|
||||||
@ -255,12 +340,18 @@ namespace GuarantorAPP.Controllers
|
|||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
if (!IsLoggedIn)
|
||||||
return RedirectToAction("IndexNonReg");
|
return RedirectToAction("IndexNonReg");
|
||||||
GuarantorBindingModel user = new() { Id = id, Login = login, Email = email, Password = password, Name = name };
|
try
|
||||||
if (_data.UpdateUser(user))
|
|
||||||
{
|
{
|
||||||
UserGuarantor.user = new GuarantorViewModel { Id = id, Login = login, Password = password, Name = name, Email = email };
|
GuarantorBindingModel user = new() { Id = id, Login = login, Email = email, Password = password, Name = name };
|
||||||
|
if (_data.UpdateUser(user))
|
||||||
|
{
|
||||||
|
UserGuarantor.user = new GuarantorViewModel { Id = id, Login = login, Password = password, Name = name, Email = email };
|
||||||
|
}
|
||||||
|
return View(user);
|
||||||
|
} catch (Exception)
|
||||||
|
{
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
}
|
}
|
||||||
return View(user);
|
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult MachineWorkshopTimeChoose()
|
public IActionResult MachineWorkshopTimeChoose()
|
||||||
@ -270,15 +361,8 @@ namespace GuarantorAPP.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult SendReport(DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
|
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
HttpContext.Session.SetString("StartDate", startDate.ToString());
|
HttpContext.Session.SetString("StartDate", startDate.ToString());
|
||||||
HttpContext.Session.SetString("EndDate", endDate.ToString());
|
HttpContext.Session.SetString("EndDate", endDate.ToString());
|
||||||
return RedirectToAction("MachineWorkshopTimeReport");
|
return RedirectToAction("MachineWorkshopTimeReport");
|
||||||
@ -286,94 +370,141 @@ namespace GuarantorAPP.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult MachineWorkshopTimeReport()
|
public IActionResult MachineWorkshopTimeReport()
|
||||||
{
|
{
|
||||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
if (!IsLoggedIn)
|
||||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
return RedirectToAction("IndexNonReg");
|
||||||
var startDate = DateTime.Parse(startDateStr);
|
try
|
||||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
{
|
||||||
|
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, UserId);
|
var values = _data.GetTimeReport(startDate, endDate, UserId);
|
||||||
ViewBag.StartDate = startDate;
|
ViewBag.StartDate = startDate;
|
||||||
ViewBag.EndDate = endDate;
|
ViewBag.EndDate = endDate;
|
||||||
return View(values);
|
return View(values);
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void MachineWorkshopTimeMail()
|
public void MachineWorkshopTimeMail()
|
||||||
{
|
{
|
||||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
try
|
||||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
|
||||||
var startDate = DateTime.Parse(startDateStr);
|
|
||||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
|
||||||
{
|
{
|
||||||
_data.SendMailReport(startDate, endDate, UserId, memoryStream);
|
var startDateStr = HttpContext.Session.GetString("StartDate");
|
||||||
|
var endDateStr = HttpContext.Session.GetString("EndDate");
|
||||||
|
var startDate = DateTime.Parse(startDateStr);
|
||||||
|
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
||||||
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
_data.SendMailReport(startDate, endDate, UserId, memoryStream);
|
||||||
|
}
|
||||||
|
Response.Redirect("MachineWorkshopTimeReport");
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
Response.Redirect("Error");
|
||||||
}
|
}
|
||||||
Response.Redirect("MachineWorkshopTimeReport");
|
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult WorkerProductChoose()
|
public IActionResult WorkerProductChoose()
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
if (!IsLoggedIn)
|
||||||
return RedirectToAction("IndexNonReg");
|
return RedirectToAction("IndexNonReg");
|
||||||
var workers = _data.GetWorkers(UserId);
|
try
|
||||||
return View(workers);
|
{
|
||||||
|
var workers = _data.GetWorkers(UserId);
|
||||||
|
return View(workers);
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("Error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult WorkerProductChoose(List<int> selectedItems, string reportType)
|
public IActionResult WorkerProductChoose(List<int> selectedItems, string reportType)
|
||||||
{
|
{
|
||||||
string value = string.Join("/", selectedItems);
|
try
|
||||||
HttpContext.Session.SetString("Workers", value);
|
{
|
||||||
if (reportType.Equals("default"))
|
string value = string.Join("/", selectedItems);
|
||||||
return RedirectToAction("WorkerProductReport");
|
HttpContext.Session.SetString("Workers", value);
|
||||||
else if (reportType.Equals("excel"))
|
if (reportType.Equals("default"))
|
||||||
return RedirectToAction("ExcelGenerate");
|
return RedirectToAction("WorkerProductReport");
|
||||||
else
|
else if (reportType.Equals("excel"))
|
||||||
return RedirectToAction("WordGenerate");
|
return RedirectToAction("ExcelGenerate");
|
||||||
|
else
|
||||||
|
return RedirectToAction("WordGenerate");
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("Error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public async Task<IActionResult> ExcelGenerate()
|
public async Task<IActionResult> ExcelGenerate()
|
||||||
{
|
{
|
||||||
var value = HttpContext.Session.GetString("Workers");
|
try
|
||||||
if (value != null)
|
|
||||||
{
|
{
|
||||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
var value = HttpContext.Session.GetString("Workers");
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
if (value != null)
|
||||||
{
|
{
|
||||||
_data.SaveReportExcel(rawReports, memoryStream);
|
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
var outputStream = new MemoryStream();
|
{
|
||||||
await memoryStream.CopyToAsync(outputStream);
|
_data.SaveReportExcel(rawReports, memoryStream);
|
||||||
outputStream.Seek(0, SeekOrigin.Begin);
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
return File(outputStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ReportExcel.xlsx");
|
var outputStream = new MemoryStream();
|
||||||
|
await memoryStream.CopyToAsync(outputStream);
|
||||||
|
outputStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return File(outputStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ReportExcel.xlsx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return RedirectToAction("WorkerProductChoose");
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
return RedirectToAction("WorkerProductChoose");
|
|
||||||
}
|
}
|
||||||
public async Task<IActionResult> WordGenerate()
|
public async Task<IActionResult> WordGenerate()
|
||||||
{
|
{
|
||||||
var value = HttpContext.Session.GetString("Workers");
|
try
|
||||||
if (value != null)
|
|
||||||
{
|
{
|
||||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
var value = HttpContext.Session.GetString("Workers");
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
if (value != null)
|
||||||
{
|
{
|
||||||
_data.SaveReportWord(rawReports, memoryStream);
|
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
var outputStream = new MemoryStream();
|
{
|
||||||
await memoryStream.CopyToAsync(outputStream);
|
_data.SaveReportWord(rawReports, memoryStream);
|
||||||
outputStream.Seek(0, SeekOrigin.Begin);
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
return File(outputStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ReportWord.docx");
|
var outputStream = new MemoryStream();
|
||||||
|
await memoryStream.CopyToAsync(outputStream);
|
||||||
|
outputStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return File(outputStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ReportWord.docx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return RedirectToAction("WorkerProductChoose");
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
return RedirectToAction("WorkerProductChoose");
|
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult WorkerProductReport()
|
public IActionResult WorkerProductReport()
|
||||||
{
|
{
|
||||||
var value = HttpContext.Session.GetString("Workers");
|
if (!IsLoggedIn)
|
||||||
if(value != null)
|
return RedirectToAction("IndexNonReg");
|
||||||
|
try
|
||||||
{
|
{
|
||||||
List<int> rawReports = value!.Split(',').Select(x => int.Parse(x)).ToList();
|
var value = HttpContext.Session.GetString("Workers");
|
||||||
var reports = _data.GetProductReports(rawReports);
|
if (value != null)
|
||||||
return View(reports);
|
{
|
||||||
|
List<int> rawReports = value!.Split(',').Select(x => int.Parse(x)).ToList();
|
||||||
|
var reports = _data.GetProductReports(rawReports);
|
||||||
|
return View(reports);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return RedirectToAction("Error");
|
||||||
}
|
}
|
||||||
return View(new List<WorkerProductReportViewModel>());
|
return View(new List<WorkerProductReportViewModel>());
|
||||||
}
|
}
|
||||||
@ -386,27 +517,36 @@ namespace GuarantorAPP.Controllers
|
|||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
if (!IsLoggedIn)
|
||||||
return RedirectToAction("IndexNonReg");
|
return RedirectToAction("IndexNonReg");
|
||||||
var workshop = _data.GetWorkshop(id);
|
try
|
||||||
ViewBag.Workshop = workshop;
|
{
|
||||||
var productions = _data.GetProductions();
|
var workshop = _data.GetWorkshop(id);
|
||||||
return View(productions);
|
ViewBag.Workshop = workshop;
|
||||||
|
var productions = _data.GetProductions();
|
||||||
|
return View(productions);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return RedirectToAction("IndexWorkshop");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult WorkshopProductionAdd(int workshopId, int productionId)
|
public IActionResult WorkshopProductionAdd(int workshopId, int productionId)
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
try
|
||||||
return RedirectToAction("IndexNonReg");
|
{
|
||||||
var workshop = _data.GetWorkshop(workshopId);
|
var workshop = _data.GetWorkshop(workshopId);
|
||||||
if (workshop == null)
|
if (workshop == null)
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
WorkshopBindingModel workshopBinding = new() { Id = workshopId, Title = workshop.Title, Address = workshop.Address, Director = workshop.Director, UserId = workshop.UserId, ProductionId = workshop.ProductionId, WorkshopWorker = workshop.WorkerWorkshops };
|
WorkshopBindingModel workshopBinding = new() { Id = workshopId, Title = workshop.Title, Address = workshop.Address, Director = workshop.Director, UserId = workshop.UserId, ProductionId = workshop.ProductionId, WorkshopWorker = workshop.WorkerWorkshops };
|
||||||
_data.UpdateWorkshop(workshopBinding);
|
_data.UpdateWorkshop(workshopBinding);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
return RedirectToAction("IndexWorkshop");
|
return RedirectToAction("IndexWorkshop");
|
||||||
}
|
}
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error(string ex)
|
||||||
{
|
{
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
return View(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,11 @@
|
|||||||
using BusinessLogic.MailWorker;
|
using BusinessLogic.BusinessLogic;
|
||||||
|
using BusinessLogic.MailWorker;
|
||||||
using BusinessLogic.OfficePackage;
|
using BusinessLogic.OfficePackage;
|
||||||
using Contracts.BindingModels;
|
using Contracts.BindingModels;
|
||||||
using Contracts.BusinessLogicsContracts;
|
using Contracts.BusinessLogicsContracts;
|
||||||
using Contracts.SearchModels;
|
using Contracts.SearchModels;
|
||||||
using Contracts.ViewModels;
|
using Contracts.ViewModels;
|
||||||
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
|
|
||||||
namespace GuarantorAPP
|
namespace GuarantorAPP
|
||||||
{
|
{
|
||||||
@ -55,6 +57,11 @@ namespace GuarantorAPP
|
|||||||
return _guarantorLogic.Update(model);
|
return _guarantorLogic.Update(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CheckLogin(string login)
|
||||||
|
{
|
||||||
|
return _guarantorLogic.ReadElement(new() { Login = login }) == null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<WorkerViewModel>? GetWorkers(int userId)
|
public List<WorkerViewModel>? GetWorkers(int userId)
|
||||||
{
|
{
|
||||||
return _workerLogic.ReadList(new WorkerSearchModel() { UserId = userId });
|
return _workerLogic.ReadList(new WorkerSearchModel() { UserId = userId });
|
||||||
@ -75,7 +82,10 @@ namespace GuarantorAPP
|
|||||||
{
|
{
|
||||||
return _workerLogic.ReadElement(new() { Id = id });
|
return _workerLogic.ReadElement(new() { Id = id });
|
||||||
}
|
}
|
||||||
|
public bool CheckWorkerName(string name)
|
||||||
|
{
|
||||||
|
return _workerLogic.ReadElement(new() { Name = name }) == null;
|
||||||
|
}
|
||||||
public List<WorkshopViewModel>? GetWorkshops(int userId)
|
public List<WorkshopViewModel>? GetWorkshops(int userId)
|
||||||
{
|
{
|
||||||
return _workshopLogic.ReadList(new WorkshopSearchModel() { UserId = userId });
|
return _workshopLogic.ReadList(new WorkshopSearchModel() { UserId = userId });
|
||||||
@ -96,8 +106,11 @@ namespace GuarantorAPP
|
|||||||
{
|
{
|
||||||
return _workshopLogic.Create(model);
|
return _workshopLogic.Create(model);
|
||||||
}
|
}
|
||||||
|
public bool CheckWorkshopTitle(string title)
|
||||||
public List<MachineViewModel>? GetMachines(int userId)
|
{
|
||||||
|
return _workshopLogic.ReadElement(new() { Title = title }) == null;
|
||||||
|
}
|
||||||
|
public List<MachineViewModel>? GetMachines(int userId)
|
||||||
{
|
{
|
||||||
return _machineLogic.ReadList(new() { UserId = userId });
|
return _machineLogic.ReadList(new() { UserId = userId });
|
||||||
}
|
}
|
||||||
@ -117,12 +130,14 @@ namespace GuarantorAPP
|
|||||||
{
|
{
|
||||||
return _machineLogic.Delete(new() { Id = machineId });
|
return _machineLogic.Delete(new() { Id = machineId });
|
||||||
}
|
}
|
||||||
|
public bool CheckMachineTitle(string title)
|
||||||
public List<ProductionViewModel>? GetProductions()
|
{
|
||||||
|
return _machineLogic.ReadElement(new() { Title = title }) == null;
|
||||||
|
}
|
||||||
|
public List<ProductionViewModel>? GetProductions()
|
||||||
{
|
{
|
||||||
return _productionLogic.ReadList(null);
|
return _productionLogic.ReadList(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MachineWorkshopTimeReport> GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId)
|
public List<MachineWorkshopTimeReport> GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId)
|
||||||
{
|
{
|
||||||
var workshops = _workshopLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, UserId = UserId });
|
var workshops = _workshopLogic.ReadList(new() { DateFrom = startDate, DateTo = endDate, UserId = UserId });
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">ФИО:</div>
|
<div class="col-4">Имя:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="text" name="fio" id="fio" value="@Model.Name" />
|
<input type="text" name="name" id="name" value="@Model.Name" />
|
||||||
<span id="fioError" class="text-danger"></span>
|
<span id="nameError" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -43,11 +43,31 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
$('#login').blur(function () {
|
||||||
|
var login = $('#login').val();
|
||||||
|
if (login.length >= 5 && login.length <= 50) {
|
||||||
|
$.ajax({
|
||||||
|
url: '@Url.Action("CheckLogin", "Home")',
|
||||||
|
type: 'POST',
|
||||||
|
data: { login: login },
|
||||||
|
success: function (response) {
|
||||||
|
if (!response.isUnique) {
|
||||||
|
$('#loginError').text('Логин уже используется.');
|
||||||
|
} else {
|
||||||
|
$('#loginError').text('');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
$('#loginError').text('Ошибка при проверке уникальности логина.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#clientForm').submit(function (event) {
|
$('#clientForm').submit(function (event) {
|
||||||
var login = $('#login').val();
|
var login = $('#login').val();
|
||||||
var email = $('#email').val();
|
var email = $('#email').val();
|
||||||
var password = $('#password').val();
|
var password = $('#password').val();
|
||||||
var fio = $('#fio').val();
|
var name = $('#name').val();
|
||||||
var isValid = true;
|
var isValid = true;
|
||||||
|
|
||||||
$('#loginError').text('');
|
$('#loginError').text('');
|
||||||
@ -74,9 +94,9 @@
|
|||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Валидация ФИО
|
// Валидация Имя
|
||||||
if (fio.length < 2 || fio.length > 20) {
|
if (name.length < 2 || name.length > 20) {
|
||||||
$('#fioError').text('ФИО должно быть от 2 до 20 символов.');
|
$('#nameError').text('Имя должно быть от 2 до 20 символов.');
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,26 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
$('#login').blur(function () {
|
||||||
|
var login = $('#login').val();
|
||||||
|
if (login.length >= 5 && login.length <= 50) {
|
||||||
|
$.ajax({
|
||||||
|
url: '@Url.Action("CheckLogin", "Home")',
|
||||||
|
type: 'POST',
|
||||||
|
data: { login: login },
|
||||||
|
success: function (response) {
|
||||||
|
if (!response.isUnique) {
|
||||||
|
$('#loginError').text('Логин уже используется.');
|
||||||
|
} else {
|
||||||
|
$('#loginError').text('');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
$('#loginError').text('Ошибка при проверке уникальности логина.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#registerForm').submit(function (event) {
|
$('#registerForm').submit(function (event) {
|
||||||
var name = $('#name').val();
|
var name = $('#name').val();
|
||||||
var login = $('#login').val();
|
var login = $('#login').val();
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<img src="~/images/Work-transformed.png" width="150" height="150" alt="Логотип">
|
<img src="~/images/Work-transformed.png" width="150" height="150" alt="Логотип">
|
||||||
<a asp-controller="Home" asp-action="Index">Приложение "Завод "Иди работать". Поручитель"</a>
|
<a asp-controller="Home" asp-action="Index" class="custom-link"><h1>Приложение "Завод "Иди работать". Поручитель"</h1></a>
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Name"]</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Name"]</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -15,4 +15,13 @@ html {
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
margin-bottom: 60px;
|
margin-bottom: 60px;
|
||||||
|
}
|
||||||
|
.custom-link {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-link:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
}
|
}
|
@ -97,7 +97,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Валидация почты
|
// Валидация почты
|
||||||
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
var emailPattern = /^[a-zA-Z0-9._-]+@@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||||||
if (!emailPattern.test(email)) {
|
if (!emailPattern.test(email)) {
|
||||||
$('#emailError').text('Неверный формат почты.');
|
$('#emailError').text('Неверный формат почты.');
|
||||||
isValid = false;
|
isValid = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user