Имитация сотрудника и отчеты
This commit is contained in:
parent
e78b2309d2
commit
608609bb45
@ -0,0 +1,131 @@
|
|||||||
|
using ZooContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ZooContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace ZooBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Замена сотрудника
|
||||||
|
/// </summary>
|
||||||
|
public class EmployeeRoleImitationaLogic
|
||||||
|
{
|
||||||
|
private readonly IEmployeeLogic _employeeLogic;
|
||||||
|
private readonly IReserveLogic _ReserveLogic;
|
||||||
|
private readonly ICostLogic _CostLogic;
|
||||||
|
private readonly IRouteLogic _RouteLogic;
|
||||||
|
private readonly IRouteCostLogic _RouteCostLogic;
|
||||||
|
|
||||||
|
public EmployeeRoleImitationaLogic(IEmployeeLogic employeeLogic,
|
||||||
|
IReserveLogic ReserveLogic, ICostLogic CostLogic,
|
||||||
|
IRouteLogic RouteLogic, IRouteCostLogic RouteCostLogic)
|
||||||
|
{
|
||||||
|
_employeeLogic = employeeLogic;
|
||||||
|
_ReserveLogic = ReserveLogic;
|
||||||
|
_CostLogic = CostLogic;
|
||||||
|
_RouteLogic = RouteLogic;
|
||||||
|
_RouteCostLogic = RouteCostLogic;
|
||||||
|
}
|
||||||
|
private bool GenerateEmployeeData()
|
||||||
|
{
|
||||||
|
if (_employeeLogic.ReadList(null)?.Count != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new("employees.txt"))
|
||||||
|
{
|
||||||
|
string? currentString;
|
||||||
|
while ((currentString = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var employeeRecData = currentString.Split(',');
|
||||||
|
_employeeLogic.Create(new()
|
||||||
|
{
|
||||||
|
EmployeeEmail = employeeRecData[0],
|
||||||
|
EmployeePassword = employeeRecData[1],
|
||||||
|
EmployeeName = employeeRecData[2],
|
||||||
|
EmployeePhone = employeeRecData[3]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private bool GenerateReserveData()
|
||||||
|
{
|
||||||
|
if (_ReserveLogic.ReadList(null)?.Count != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new("Reserves.txt"))
|
||||||
|
{
|
||||||
|
string? currentString;
|
||||||
|
while ((currentString = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var ReserveRecData = currentString.Split(',');
|
||||||
|
_ReserveLogic.Create(new()
|
||||||
|
{
|
||||||
|
ReserveName = Convert.ToString(ReserveRecData[0]),
|
||||||
|
ReservePrice = Convert.ToDouble(ReserveRecData[1])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool GenerateCost()
|
||||||
|
{
|
||||||
|
if (_CostLogic.ReadList(null)?.Count != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
using (StreamReader sr = new("Costs.txt"))
|
||||||
|
{
|
||||||
|
string? currentString;
|
||||||
|
while ((currentString = sr.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
var CostRecData = currentString.Split(',');
|
||||||
|
_CostLogic.Create(new()
|
||||||
|
{
|
||||||
|
CostName = Convert.ToString(CostRecData[0]),
|
||||||
|
Sum = Convert.ToDouble(CostRecData[1]),
|
||||||
|
Count = Convert.ToInt32(CostRecData[2]),
|
||||||
|
EmployeeId = Convert.ToInt32(CostRecData[3])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool GenerateRouteCost()
|
||||||
|
{
|
||||||
|
var CostList = _CostLogic.ReadList(null);
|
||||||
|
if (CostList == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (CostList.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var RouteList = _RouteLogic.ReadList(null);
|
||||||
|
if (RouteList == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (RouteList.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Random rnd = new Random();
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
_RouteCostLogic.Create(new()
|
||||||
|
{
|
||||||
|
CostId = rnd.Next(0, CostList.Count),
|
||||||
|
RouteId = rnd.Next(0, RouteList.Count)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,33 +1,42 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using Microsoft.Identity.Client;
|
||||||
using System.Collections.Generic;
|
using ZooContracts.BusinessLogicsContracts;
|
||||||
using System.Linq;
|
using ZooContracts.StoragesContracts;
|
||||||
using System.Text;
|
using ZooContracts.ViewModels;
|
||||||
using System.Threading.Tasks;
|
using ZooDatabaseImplement.Models;
|
||||||
|
using ZooDataModels.Models;
|
||||||
using ZooContracts.BindingModels;
|
using ZooContracts.BindingModels;
|
||||||
using ZooContracts.BusinessLogicsContracts;
|
using ZooContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
namespace ZooBusinessLogic.BusinessLogics
|
namespace ZooContracts.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ReportLogic : IReportLogic
|
public class ReportLogic : IReportLogic
|
||||||
{
|
{
|
||||||
private readonly IRouteStorage _RouteStorage;
|
private readonly IRouteStorage _RouteStorage;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly IRouteCostStorage _RouteCostStorage;
|
||||||
|
|
||||||
public ReportLogic(ILogger _logger, IRouteStorage RouteStorage)
|
public ReportLogic(ILogger logger, IRouteStorage RouteStorage,
|
||||||
|
IRouteCostStorage RouteCostStorage)
|
||||||
{
|
{
|
||||||
//_logger = logger;
|
_logger = logger;
|
||||||
_RouteStorage = RouteStorage;
|
_RouteStorage = RouteStorage;
|
||||||
|
_RouteCostStorage = RouteCostStorage;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка кружков с указанием списка затрат по ним за определенное время
|
/// получение заповедников в маршруте
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
|
||||||
public List<ReportRouteReservesViewModel> GetReserveRoutes(ReportBindingModel model)
|
public List<ReportRouteReservesViewModel> GetReserveRoutes(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
return _RouteStorage.GetReserveRoutes(new() { SelectedRoutesIds = model.SelectedRoutes });
|
return _RouteStorage.GetReserveRoutes(new() { SelectedRoutesIds = model.SelectedRoutes });
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// получение затрат по маршруту
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportCostsInRoutesViewModel> GetCosts(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
return _RouteCostStorage.GetCostsInRoutes(new() { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||||
|
}
|
||||||
public void SaveComponentsToWordFile(ReportBindingModel model)
|
public void SaveComponentsToWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@ -43,4 +52,4 @@ namespace ZooBusinessLogic.BusinessLogics
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ZooBusinessLogic.BusinessLogics
|
|
||||||
{
|
|
||||||
internal class ReportReserveLogic
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,5 +12,7 @@ namespace ZooContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
public string CostName { get; set; }
|
public string CostName { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,5 @@ namespace ZooContracts.BindingModels
|
|||||||
public DateTime DateStart { get; set; } = DateTime.Now;
|
public DateTime DateStart { get; set; } = DateTime.Now;
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
public int ReserveId { get; set; }
|
public int ReserveId { get; set; }
|
||||||
public double Remains { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,16 @@ namespace ZooContracts.BusinessLogicsContracts
|
|||||||
public interface IReportLogic
|
public interface IReportLogic
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка Маршрутов по заповедникам
|
/// Получение списка маршрутов по заповедникам
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<ReportRouteReservesViewModel> GetReserveRoutes(ReportBindingModel model);
|
List<ReportRouteRoutesViewModel> GetRouteRoutes(ReportBindingModel model);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка затрат за определенный период
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<ReportCostsInRoutesViewModel> GetCosts(ReportBindingModel model);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранение компонент в файл-Word
|
/// Сохранение компонент в файл-Word
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -23,7 +29,7 @@ namespace ZooContracts.BusinessLogicsContracts
|
|||||||
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model"></param>
|
/// <param name="model"></param>
|
||||||
void SaveComponentToExcelFile(ReportBindingModel model);
|
void SaveManufactureComponentToExcelFile(ReportBindingModel model);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранение заказов в файл-Pdf
|
/// Сохранение заказов в файл-Pdf
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -9,5 +9,7 @@ namespace ZooContracts.SearchModel
|
|||||||
public class RouteCostSearchModel
|
public class RouteCostSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,6 @@ namespace ZooContracts.StoragesContracts
|
|||||||
RouteCostViewModel? Insert(RouteCostBindingModel model);
|
RouteCostViewModel? Insert(RouteCostBindingModel model);
|
||||||
RouteCostViewModel? Update(RouteCostBindingModel model);
|
RouteCostViewModel? Update(RouteCostBindingModel model);
|
||||||
RouteCostViewModel? Delete(RouteCostBindingModel model);
|
RouteCostViewModel? Delete(RouteCostBindingModel model);
|
||||||
|
List<ReportCostsInRoutesViewModel> GetExpensesInCircles(RouteCostSearchModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,7 @@ namespace ZooContracts.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string CostName { get; set; }
|
public string CostName { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,17 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ZooContracts.ViewModels
|
namespace ZooContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class ReportCostViewModel
|
public class ReportCostsInRoutesViewModel
|
||||||
{
|
{
|
||||||
[DisplayName("Название затраты")]
|
[DisplayName("Название затраты")]
|
||||||
public string CostName { get; set; } = string.Empty;
|
public string CostName { get; set; } = string.Empty;
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
[DisplayName("Номер маршрута")]
|
||||||
|
public int CircleId { get; set; }
|
||||||
|
[DisplayName("Имя сотрудника")]
|
||||||
|
public string EmployeeName { get; set; }
|
||||||
|
[DisplayName("Кол-во затрат")]
|
||||||
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,17 @@ namespace ZooContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportReserveRoutesViewModel
|
public class ReportReserveRoutesViewModel
|
||||||
{
|
{
|
||||||
public int ReserveId { get; set; }
|
/// <summary>
|
||||||
public int RoutesCount { get; set; }
|
/// Номер заповедника
|
||||||
|
/// </summary>
|
||||||
|
public int ReserveId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Имя работника
|
||||||
|
/// </summary>
|
||||||
|
public string EmployeeName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Стоимость
|
||||||
|
/// </summary>
|
||||||
|
public double Sum { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,6 @@ namespace ZooContracts.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Заповедник в Маршруте
|
/// Заповедник в Маршруте
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportReserveRouteViewModel> RouteLessons { get; set; } = new();
|
public List<ReportReserveRouteViewModel> Lessons { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ZooContracts.ViewModels
|
|
||||||
{
|
|
||||||
public class ReportViewModel
|
|
||||||
{
|
|
||||||
[DisplayName("Название маршрута")]
|
|
||||||
public int RouteNumber { get; set; }
|
|
||||||
[DisplayName("Дата записи")]
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
[DisplayName("Сумма затрат")]
|
|
||||||
public double Sum { get; set; }
|
|
||||||
[DisplayName("Кол-во заповедников")]
|
|
||||||
public int RouteCount { get; set; }
|
|
||||||
[DisplayName("Название затраты")]
|
|
||||||
public List<ReportCostViewModel> Cost { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,5 +16,13 @@ namespace ZooDataModels.Models
|
|||||||
/// Название
|
/// Название
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CostName { get; }
|
public string CostName { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// количество
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Id сотрудника
|
||||||
|
/// </summary>
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,26 @@ namespace ZooDatabaseImplements.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportCostsInRoutesViewModel> GetCostsInRoutes(RouteCostSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.DateFrom == null || model.DateTo == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new ZooDatabase();
|
||||||
|
return context.RouteCosts.Include(x => x.Route)
|
||||||
|
.Include(x => x.Cost)
|
||||||
|
.ThenInclude(x => x.Employee)
|
||||||
|
.Select(x => new ReportCostsInRoutesViewModel()
|
||||||
|
{
|
||||||
|
EmployeeName = x.Cost.Employee.EmployeeName,
|
||||||
|
RouteId = x.Route.Id,
|
||||||
|
CostName = x.Cost.CostName,
|
||||||
|
Count = x.Cost.Count,
|
||||||
|
Sum = x.Cost.Sum
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
public List<RouteCostViewModel> GetFilteredList(RouteCostSearchModel model)
|
public List<RouteCostViewModel> GetFilteredList(RouteCostSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new ZooDatabase();
|
using var context = new ZooDatabase();
|
||||||
|
@ -25,22 +25,11 @@ namespace ZooDatabaseImplements.Implements
|
|||||||
public List<RouteViewModel> GetFilteredList(RouteSearchModel model)
|
public List<RouteViewModel> GetFilteredList(RouteSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new ZooDatabase();
|
using var context = new ZooDatabase();
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по id, значит ищем по диапазону дат
|
return context.Routes
|
||||||
{
|
.Where(x => x.Id == model.Id)
|
||||||
return context.Routes
|
.Include(x => x.Client)
|
||||||
.Where(x => model.DateFrom <= x.DateStart.Date && x.DateStart <= model.DateTo)
|
.Select(x => x.GetViewModel)
|
||||||
.Include(x => x.Client)
|
.ToList();
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
if (model.ClientId.HasValue)
|
|
||||||
{
|
|
||||||
return context.Routes
|
|
||||||
.Where(x => x.Client.Id == model.ClientId)
|
|
||||||
.Select(x => x.GetViewModel)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
return new();
|
|
||||||
}
|
}
|
||||||
public RouteViewModel? GetElement(RouteSearchModel model)
|
public RouteViewModel? GetElement(RouteSearchModel model)
|
||||||
{
|
{
|
||||||
@ -92,7 +81,11 @@ namespace ZooDatabaseImplements.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка заповедников по выбранному маршруту
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public List<ReportRouteReservesViewModel> GetReserveRoutes(RouteSearchModel model)
|
public List<ReportRouteReservesViewModel> GetReserveRoutes(RouteSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.SelectedRoutesIds == null)
|
if (model.SelectedRoutesIds == null)
|
||||||
@ -101,26 +94,23 @@ namespace ZooDatabaseImplements.Implements
|
|||||||
}
|
}
|
||||||
using var context = new ZooDatabase();
|
using var context = new ZooDatabase();
|
||||||
return context.Routes
|
return context.Routes
|
||||||
.Where(c => model.SelectedRoutesIds.Contains(c.Id))
|
.Where(x => model.SelectedRoutesIds.Contains(x.Id))
|
||||||
.Select(c => new ReportRouteReservesViewModel()
|
.Select(x => new ReportRouteReservesViewModel()
|
||||||
{
|
{
|
||||||
RouteReserves = GetRouteReserves(context, new() { Id = c.Id })
|
RouteId = x.Id,
|
||||||
})
|
Reserves = context.RouteReserves
|
||||||
.ToList();
|
.Include(x => x.Reserve)
|
||||||
}
|
.ThenInclude(x => x.Employee)
|
||||||
/// <summary>
|
.Where(x => x.RouteId == x.Id)
|
||||||
/// Получение списка заповедников по выбранному маршруту
|
.Select(x => new ReportReserveRoutesViewModel()
|
||||||
/// </summary>
|
{
|
||||||
/// <param name="model"></param>
|
|
||||||
/// <returns></returns>
|
ReserveId = x.Route.Id,
|
||||||
private static List<ReportReserveRoutesViewModel> GetRouteReserves(ZooDatabase context, RouteSearchModel model)
|
EmployeeName = x.Reserve.Employee.EmployeeName,
|
||||||
{
|
Sum = x.Reserve.ReservePrice
|
||||||
return context.Routes
|
|
||||||
.Include(wir => wir.RouteReserves)
|
})
|
||||||
.Where(wir => wir.Id == model.Id)
|
.ToList()
|
||||||
.Select(wir => new ReportReserveRoutesViewModel()
|
|
||||||
{
|
|
||||||
ReserveId = wir.RouteReserves.Id
|
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,15 @@ namespace ZooDatabaseImplements.Models
|
|||||||
public string CostName { get; private set; } = string.Empty;
|
public string CostName { get; private set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
|
[Required]
|
||||||
|
public int Count { get; private set; }
|
||||||
|
public int EmployeeId { get; private set; }
|
||||||
|
public int RouteId { get; private set; }
|
||||||
[ForeignKey("CostId")]
|
[ForeignKey("CostId")]
|
||||||
public virtual List<RouteCost> RouteCosts { get; set; } = new();
|
public virtual List<RouteCost> RouteCosts { get; set; } = new();
|
||||||
public static Cost? Create(CostBindingModel model)
|
[ForeignKey("CostId")]
|
||||||
|
public virtual Employee Employee { get; set; } = new();
|
||||||
|
public static Cost? Create(ZooDatabase context, CostBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -29,7 +35,9 @@ namespace ZooDatabaseImplements.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
CostName = model.CostName,
|
CostName = model.CostName,
|
||||||
Sum = model.Sum
|
Sum = model.Sum,
|
||||||
|
Count = model.Count,
|
||||||
|
Employee = context.Employees.First(x => x.Id == model.EmployeeId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(CostBindingModel model)
|
public void Update(CostBindingModel model)
|
||||||
|
@ -23,6 +23,8 @@ namespace ZooDatabaseImplements.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string EmployeeName { get; set; } = string.Empty;
|
public string EmployeeName { get; set; } = string.Empty;
|
||||||
[ForeignKey("EmployeeId")]
|
[ForeignKey("EmployeeId")]
|
||||||
|
public virtual List<Cost> Costs { get; set; } = new();
|
||||||
|
[ForeignKey("CostId")]
|
||||||
public virtual List<Reserve> Reserves { get; set; } = new();
|
public virtual List<Reserve> Reserves { get; set; } = new();
|
||||||
public static Employee? Create(EmployeeBindingModel model)
|
public static Employee? Create(EmployeeBindingModel model)
|
||||||
{
|
{
|
||||||
@ -51,9 +53,13 @@ namespace ZooDatabaseImplements.Models
|
|||||||
EmployeePhone = model.EmployeePhone;
|
EmployeePhone = model.EmployeePhone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CostViewModel GetViewModel => new()
|
public EmployeeViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id
|
Id = Id,
|
||||||
|
EmployeeName = EmployeeName,
|
||||||
|
EmployeeEmail = EmployeeEmail,
|
||||||
|
EmployeePassword = EmployeePassword,
|
||||||
|
EmployeePhone = EmployeePhone
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user