изменения
This commit is contained in:
parent
2132887869
commit
1380e5d3cf
@ -28,17 +28,17 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model.Login), "Нет логина клиента");
|
||||
throw new ArgumentNullException(nameof(model.PhoneNumber), "Нет логина клиента");
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model.Password), "Нет пароля клиента");
|
||||
}
|
||||
if (model.Login.Length is < 5)
|
||||
if (model.PhoneNumber.Length is < 11)
|
||||
{
|
||||
throw new ArgumentException(nameof(model.Login), "Длина логина должна быть 5 символов");
|
||||
throw new ArgumentException(nameof(model.PhoneNumber), "Длина номера телефона должна быть 11 цифр");
|
||||
}
|
||||
|
||||
if (model.Password.Length < 5)
|
||||
@ -54,11 +54,11 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
_logger.LogDebug("{level} Проверка логина пользователя на уникальность {@Client}", model);
|
||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||
{
|
||||
Login = model.Login,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
_logger.LogWarning("С номером {Login}, уже есть пользователь: {@ExistClient}", model.Login, element);
|
||||
_logger.LogWarning("С номером {PhoneNumber}, уже есть пользователь: {@ExistClient}", model.PhoneNumber, element);
|
||||
throw new InvalidOperationException($"Клиент с таким номером телефона уже есть");
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
public EmployeeLogic(ILogger<EmployeeLogic> logger, IEmployeeStorage employeeStorage)
|
||||
@ -33,17 +34,17 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model.Login), "Нет логина клиента");
|
||||
throw new ArgumentNullException(nameof(model.PhoneNumber), "Нет логина клиента");
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model.Password), "Нет пароля клиента");
|
||||
}
|
||||
if (model.Login.Length is < 5)
|
||||
if (model.PhoneNumber.Length is < 12)
|
||||
{
|
||||
throw new ArgumentException(nameof(model.Login), "Длина номера телефона должна быть 11 цифр");
|
||||
throw new ArgumentException(nameof(model.PhoneNumber), "Длина номера телефона должна быть 11 цифр");
|
||||
}
|
||||
|
||||
if (model.Password.Length < 5)
|
||||
@ -59,12 +60,12 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
_logger.LogDebug("{level} Проверка логина пользователя на уникальность {@Employee}", model);
|
||||
var element = _employeeStorage.GetElement(new EmployeeSearchModel
|
||||
{
|
||||
Login = model.Login,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
_logger.LogWarning("С номером {Login}, уже есть пользователь: {@ExistEmployee}", model.Login, element);
|
||||
throw new InvalidOperationException($"Сотрудник с таким логином уже есть");
|
||||
_logger.LogWarning("С номером {PhoneNumber}, уже есть пользователь: {@ExistEmployee}", model.PhoneNumber, element);
|
||||
throw new InvalidOperationException($"Сотрудник с таким номером телефона уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,4 +108,5 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,74 +1,72 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BusinessLogicContracts;
|
||||
using UniversityContracts.BindingModels;
|
||||
|
||||
using UniversityContracts.BusinessLogicContracts;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
public class ClassLogic : IClassLogic
|
||||
public class OperationLogic : IOperationLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClassStorage _carStorage;
|
||||
private readonly IOperationStorage _carStorage;
|
||||
|
||||
public ClassLogic(ILogger<ClassLogic> logger, IClassStorage carStorage)
|
||||
public OperationLogic(ILogger<OperationLogic> logger, IOperationStorage carStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_carStorage = carStorage;
|
||||
}
|
||||
|
||||
public void CheckOnlyModel(ClassBindingModel model)
|
||||
public void CheckOnlyModel(OperationBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model), "Произошла ошибка на уровне проверки ClassBindingModel");
|
||||
throw new ArgumentNullException(nameof(model), "Произошла ошибка на уровне проверки OperationBindingModel");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckUpdateModel(ClassBindingModel model)
|
||||
private void CheckUpdateModel(OperationBindingModel model)
|
||||
{
|
||||
CheckOnlyModel(model);
|
||||
if (model.Price <= 0)
|
||||
{
|
||||
throw new ArgumentException($"Произошла ошибка на уровне проверки ClassBindingModel. Стоимость операции (Price={model.Price}) должна быть больше 0");
|
||||
throw new ArgumentException($"Произошла ошибка на уровне проверки OperationBindingModel. Стоимость операции (Price={model.Price}) должна быть больше 0");
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckFullModel(ClassBindingModel model)
|
||||
public void CheckFullModel(OperationBindingModel model)
|
||||
{
|
||||
CheckOnlyModel(model);
|
||||
CheckUpdateModel(model);
|
||||
if (string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.Time))
|
||||
if (string.IsNullOrEmpty(model.Model) && string.IsNullOrEmpty(model.Mark))
|
||||
{
|
||||
throw new ArgumentNullException($"Произошла ошибка на уровне проверки ClassBindingModel.Вид и тип операции не должна быть нулевыми или пустыми.");
|
||||
throw new ArgumentNullException($"Произошла ошибка на уровне проверки OperationBindingModel.Вид и тип операции не должна быть нулевыми или пустыми.");
|
||||
}
|
||||
}
|
||||
|
||||
public List<ClassViewModel> ReadList(ClassSearchModel? model)
|
||||
public List<OperationViewModel> ReadList(OperationSearchModel? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var results = model != null ? _carStorage.GetFilteredList(model) : _carStorage.GetFullList();
|
||||
_logger.LogDebug("Список операций: {@classes}", results);
|
||||
_logger.LogInformation("Извлечение списка операций по {@ClassSearchModel} модели", model);
|
||||
_logger.LogDebug("Список операций: {@operations}", results);
|
||||
_logger.LogInformation("Извлечение списка операций по {@OperationSearchModel} модели", model);
|
||||
return results;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Произошла ошибка при попытки получить список по {@ClassSearchModel} модели", model);
|
||||
_logger.LogError(e, "Произошла ошибка при попытки получить список по {@OperationSearchModel} модели", model);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public ClassViewModel ReadElement(ClassSearchModel model)
|
||||
public OperationViewModel ReadElement(OperationSearchModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -77,17 +75,17 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException($"Не получилось получить эдемент с id {model.Id}");
|
||||
}
|
||||
_logger.LogInformation("Извлечение элемента {@ClassViewModel} c обследований по {@ClassSearchModel} модели", result, model);
|
||||
_logger.LogInformation("Извлечение элемента {@OperationViewModel} c обследований по {@OperationSearchModel} модели", result, model);
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Произошла ошибка при попытки получить элемент по {@ClassSearchModel} модели:", model);
|
||||
_logger.LogError(e, "Произошла ошибка при попытки получить элемент по {@OperationSearchModel} модели:", model);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Create(ClassBindingModel model)
|
||||
public bool Create(OperationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -97,17 +95,17 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException($"Не получилось создать операцию");
|
||||
}
|
||||
_logger.LogInformation("Создана сущность {@ClassViewModel}", result);
|
||||
_logger.LogInformation("Создана сущность {@OperationViewModel}", result);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Произошла ошибка при попытки создать элемент по {@ClassBindingModel} модели", model);
|
||||
_logger.LogError(e, "Произошла ошибка при попытки создать элемент по {@OperationBindingModel} модели", model);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update(ClassBindingModel model)
|
||||
public bool Update(OperationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -117,17 +115,17 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException($"Результат обновления обследований оказался нулевым");
|
||||
}
|
||||
_logger.LogInformation("Была обновлена сущность на: {@ClassViewModel}", result);
|
||||
_logger.LogInformation("Была обновлена сущность на: {@OperationViewModel}", result);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Произошла ошибка при попытки обновить элемент по модели: {@ClassBindingModel}", model);
|
||||
_logger.LogError(e, "Произошла ошибка при попытки обновить элемент по модели: {@OperationBindingModel}", model);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Delete(ClassBindingModel model)
|
||||
public bool Delete(OperationBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -137,12 +135,12 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException($"Не получилось удалить операциб");
|
||||
}
|
||||
_logger.LogInformation("Удалена сущность {@ClassViewModel}", result);
|
||||
_logger.LogInformation("Удалена сущность {@OperationViewModel}", result);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Произошла ошибка при попытки удалить элемент по {@ClassBindingModel} модели", model);
|
||||
_logger.LogError(e, "Произошла ошибка при попытки удалить элемент по {@OperationBindingModel} модели", model);
|
||||
throw;
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPaymentStorage _paymentStorage;
|
||||
private readonly IClassStorage _carStorage;
|
||||
public PaymentLogic(ILogger<PaymentLogic> logger, IPaymentStorage paymentStorage, IClassStorage carStorage)
|
||||
private readonly IOperationStorage _carStorage;
|
||||
public PaymentLogic(ILogger<PaymentLogic> logger, IPaymentStorage paymentStorage, IOperationStorage carStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_paymentStorage = paymentStorage;
|
||||
@ -101,13 +101,13 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
var payments = ReadList(model); // Вызываем метод из бизнес логики, чтобы залогировать доп информацию
|
||||
if (payments == null || payments.Count == 0)
|
||||
{
|
||||
fullPrice = _carStorage.GetElement(new() { Id = model.ClassId })?.Price ?? throw new InvalidOperationException("Не получена операция для оплаты"); ;
|
||||
fullPrice = _carStorage.GetElement(new() { Id = model.OperationId })?.Price ?? throw new InvalidOperationException("Не получена операция для оплаты"); ;
|
||||
paidPrice = 0;
|
||||
return true;
|
||||
}
|
||||
fullPrice = payments[0].FullPrice;
|
||||
paidPrice = payments.Sum(x => x.PaidPrice);
|
||||
_logger.LogInformation("По покупке({Id}) и операцийе({Id}) получена полная стоимостиь {fullPrice} и оплаченная стоимость {paidPrice}", model.PurchaseId, model.ClassId, fullPrice, paidPrice);
|
||||
_logger.LogInformation("По покупке({Id}) и операцийе({Id}) получена полная стоимостиь {fullPrice} и оплаченная стоимость {paidPrice}", model.PurchaseId, model.OperationId, fullPrice, paidPrice);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -15,14 +15,14 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
{
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly IPurchaseStorage _purchaseStorage;
|
||||
private readonly IClassStorage _carStorage;
|
||||
private readonly IOperationStorage _carStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly IPaymentStorage _paymentStorage;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
|
||||
public ReportLogic(AbstractSaveToWord saveToWord, IPurchaseStorage purchaseStorage, AbstractSaveToExcel saveToExcel,
|
||||
AbstractMailWorker mailWorker, IPaymentStorage paymentStorage, AbstractSaveToPdf saveToPdf, IClassStorage carStorage)
|
||||
AbstractMailWorker mailWorker, IPaymentStorage paymentStorage, AbstractSaveToPdf saveToPdf, IOperationStorage carStorage)
|
||||
{
|
||||
_mailWorker = mailWorker;
|
||||
_paymentStorage = paymentStorage;
|
||||
@ -40,7 +40,7 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
FileName = option.FileName,
|
||||
Stream = option.Stream,
|
||||
Title = "Список сделок вместе с операциями",
|
||||
ReportObjects = _purchaseStorage.GetFilteredList(new() { ClassesIds = option.Ids.ToList() })
|
||||
ReportObjects = _purchaseStorage.GetFilteredList(new() { OperationsIds = option.Ids.ToList() })
|
||||
.Select(x => (object)x).ToList(),
|
||||
});
|
||||
}
|
||||
@ -52,7 +52,7 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
FileName = option.FileName,
|
||||
Stream = option.Stream,
|
||||
Title = "Список сделок вместе с операциями",
|
||||
ReportObjects = _purchaseStorage.GetFilteredList(new() { ClassesIds = option.Ids.ToList() })
|
||||
ReportObjects = _purchaseStorage.GetFilteredList(new() { OperationsIds = option.Ids.ToList() })
|
||||
.Select(x => (object)x).ToList(),
|
||||
Headers = new() { "Сделка", "Дата сделки", }
|
||||
});
|
||||
@ -135,3 +135,4 @@ namespace UniversityBusinessLogics.BusinessLogic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
int i = 0;
|
||||
foreach (var car in purchase.ClassViewModels)
|
||||
foreach (var car in purchase.OperationViewModels)
|
||||
{
|
||||
if (info.Ids != null && !info.Ids.Contains(car.Id))
|
||||
{
|
||||
@ -81,7 +81,7 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
{
|
||||
ColumnName = ((char)('C' + i)).ToString(),
|
||||
RowIndex = rowIndex,
|
||||
Text = $"{car.Time} {car.Name} в количестве {purchase.ClassModel[car.Id].CountClass}",
|
||||
Text = $"{car.Mark} {car.Model} в количестве {purchase.OperationsModel[car.Id].CountOperations}",
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
if (info.Ids != null)
|
||||
@ -103,7 +103,7 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
uint rowIndex = 3;
|
||||
foreach (var pc in info.ReportObjects)
|
||||
{
|
||||
var car = pc as ClassViewModel;
|
||||
var car = pc as OperationViewModel;
|
||||
if (car == null)
|
||||
{
|
||||
throw new ArgumentException($"Передан некорректный тип в отчет: " +
|
||||
@ -119,21 +119,21 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = car.Time,
|
||||
Text = car.Mark,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = car.Name,
|
||||
Text = car.Model,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = purchase.ClassModel[car.Id].CountClass.ToString(),
|
||||
Text = purchase.OperationsModel[car.Id].CountOperations.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
@ -172,6 +172,5 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SaveExcel(ExcelInfo info);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
$"ожидается Payment; Получен объект типа: {pc.GetType()}", nameof(info));
|
||||
}
|
||||
|
||||
if (payment.Operation == null || payment.ClassByPurchase == null)
|
||||
if (payment.Operation == null || payment.OperationByPurchase == null)
|
||||
{
|
||||
throw new ArgumentNullException($"Получена модель оплаты c нулевыми полями");
|
||||
}
|
||||
@ -49,8 +49,8 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
{
|
||||
Texts = new List<string>
|
||||
{
|
||||
payment.ClassByPurchase.PurchaseId.ToString(),
|
||||
payment.Operation.Time + " " + payment.Operation.Name,
|
||||
payment.OperationByPurchase.PurchaseId.ToString(),
|
||||
payment.Operation.Mark + " " + payment.Operation.Model,
|
||||
payment.Date.ToShortDateString(),
|
||||
payment.PaidPrice.ToString(),
|
||||
payment.FullPrice.ToString(),
|
||||
@ -145,6 +145,5 @@ namespace UniversityBusinessLogics.OfficePackage
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,18 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="1.50.5147" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
@ -19,7 +19,7 @@ builder.Services.AddSession(); //
|
||||
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
|
||||
builder.Services.AddTransient<IClassLogic, ClassLogic>();
|
||||
builder.Services.AddTransient<IOperationLogic, OperationLogic>();
|
||||
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
builder.Services.AddTransient<IPaymentLogic, PaymentLogic>();
|
||||
|
||||
@ -29,7 +29,7 @@ builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
|
||||
builder.Services.AddTransient<IClassStorage, ClassStorage>();
|
||||
builder.Services.AddTransient<IOperationStorage, OperationStorage>();
|
||||
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
|
||||
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
@ -7,17 +7,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
|
@ -11,7 +11,7 @@ namespace UniversityContracts.BindingModels
|
||||
|
||||
public string? MiddleName { get; set; }
|
||||
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
@ -19,4 +19,5 @@ namespace UniversityContracts.BindingModels
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
{
|
||||
public class CostBindingModel
|
||||
public class CostBindingModel : ICostModel
|
||||
{
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
|
@ -12,14 +12,12 @@ namespace UniversityContracts.BindingModels
|
||||
|
||||
public string? MiddleName { get; set; }
|
||||
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels;
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
{
|
||||
public class ClassBindingModel
|
||||
public class OperationBindingModel : IOperationModel
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Model { get; set; } = string.Empty;
|
||||
|
||||
public string Time { get; set; } = string.Empty;
|
||||
public string Mark { get; set; } = string.Empty;
|
||||
|
||||
public double Price { get; set; }
|
||||
|
@ -3,18 +3,18 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels;
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
{
|
||||
public class PaymentBindingModel
|
||||
public class PaymentBindingModel : IPaymentModel
|
||||
{
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
public DateOnly Date { get; set; } = DateOnly.FromDateTime(DateTime.Now);
|
||||
|
||||
public double PaidPrice { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ClassByPurchaseId { get; set; }
|
||||
public int OperationByPurchaseId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using UniversityDataModels;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
|
||||
namespace UniversityContracts.BindingModels
|
||||
{
|
||||
@ -8,7 +9,7 @@ namespace UniversityContracts.BindingModels
|
||||
{
|
||||
public int ClientId { get; set; }
|
||||
public DateOnly DatePurchase { get; set; }
|
||||
public Dictionary<int, ClassByPurchaseModel> ClassModel { get; set; } = new();
|
||||
public Dictionary<int, OperationByPurchaseModel> OperationsModel { get; set; } = new();
|
||||
public List<CostByPurchaseModel> CostsModel { get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
|
@ -1,15 +0,0 @@
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IClassLogic
|
||||
{
|
||||
List<ClassViewModel> ReadList(ClassSearchModel? model = null);
|
||||
ClassViewModel ReadElement(ClassSearchModel model);
|
||||
bool Create(ClassBindingModel model);
|
||||
bool Update(ClassBindingModel model);
|
||||
bool Delete(ClassBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IOperationLogic
|
||||
{
|
||||
List<OperationViewModel> ReadList(OperationSearchModel? model = null);
|
||||
OperationViewModel ReadElement(OperationSearchModel model);
|
||||
bool Create(OperationBindingModel model);
|
||||
bool Update(OperationBindingModel model);
|
||||
bool Delete(OperationBindingModel model);
|
||||
}
|
||||
}
|
@ -19,6 +19,5 @@ namespace UniversityContracts.BusinessLogicContracts
|
||||
void SaveOperationsToExcel(ReportBindingModel option);
|
||||
|
||||
void SendCostsToEmail(ReportDateRangeBindingModel option, string email);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
namespace UniversityContracts.SearchModels
|
||||
{
|
||||
public class ClassSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Time { get; set; } = string.Empty;
|
||||
public int Price { get; set; }
|
||||
public List<int>? PurchasesIds { get; set; }
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Login { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
public class EmployeeSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Login { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityContracts.SearchModels
|
||||
{
|
||||
public class OperationSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public string Model { get; set; } = string.Empty;
|
||||
public string Mark { get; set; } = string.Empty;
|
||||
public int Price { get; set; }
|
||||
public List<int>? PurchasesIds { get; set; }
|
||||
}
|
||||
}
|
@ -9,10 +9,10 @@ namespace UniversityContracts.SearchModels
|
||||
public class PaymentSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClassId { get; set; }
|
||||
public int? OperationId { get; set; }
|
||||
public int? PurchaseId { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public DateOnly? DateFrom { get; set; }
|
||||
public DateOnly? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -7,6 +7,6 @@
|
||||
public DateOnly? DateFrom { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
public List<int>? ClassesIds { get; set; }
|
||||
public List<int>? OperationsIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
|
||||
namespace UniversityContracts.StoragesContracts
|
||||
{
|
||||
public interface IClassStorage
|
||||
{
|
||||
List<ClassViewModel> GetFullList();
|
||||
List<ClassViewModel> GetFilteredList(ClassSearchModel model);
|
||||
ClassViewModel? GetElement(ClassSearchModel model);
|
||||
ClassViewModel? Insert(ClassBindingModel model);
|
||||
ClassViewModel? Update(ClassBindingModel model);
|
||||
ClassViewModel? Delete(ClassBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
|
||||
namespace UniversityContracts.StoragesContracts
|
||||
{
|
||||
public interface IOperationStorage
|
||||
{
|
||||
List<OperationViewModel> GetFullList();
|
||||
List<OperationViewModel> GetFilteredList(OperationSearchModel model);
|
||||
OperationViewModel? GetElement(OperationSearchModel model);
|
||||
OperationViewModel? Insert(OperationBindingModel model);
|
||||
OperationViewModel? Update(OperationBindingModel model);
|
||||
OperationViewModel? Delete(OperationBindingModel model);
|
||||
}
|
||||
}
|
@ -15,6 +15,6 @@ namespace UniversityContracts.StoragesContracts
|
||||
PurchaseViewModel? Update(PurchaseBindingModel model);
|
||||
PurchaseViewModel? Delete(PurchaseBindingModel model);
|
||||
|
||||
List<PaymentViewModel> GetPaymentsFromPurchaseAndOperation(PurchaseSearchModel modelPurchase, ClassSearchModel modelClass);
|
||||
List<PaymentViewModel> GetPaymentsFromPurchaseAndOperation(PurchaseSearchModel modelPurchase, OperationSearchModel modelOperation);
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
using UniversityDataModels;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class ClassViewModel : IClassModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("Логин сотрудника")]
|
||||
public string EmployeeLogin { get; set; } = string.Empty;
|
||||
[DisplayName("Стоимость")]
|
||||
public double Price { get; set; }
|
||||
[DisplayName("Вид операции")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Тип операции")]
|
||||
public string Time { get; set; } = string.Empty;
|
||||
[JsonIgnore]
|
||||
public List<PurchaseViewModel> Purchases { get; set; } = new();
|
||||
public override string ToString()
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
foreach (var purchase in Purchases)
|
||||
{
|
||||
result.Append($"Операция вида {Name},Типа {Time}, Купленная {purchase.DatePurchase.ToShortDateString()}," +
|
||||
$"в покупе c id: {purchase.Id}\n");
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -14,8 +14,8 @@ namespace UniversityContracts.ViewModels
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
[DisplayName("Отчество")]
|
||||
public string? MiddleName { get; set; } = string.Empty;
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels;
|
||||
using UniversityDataModels;
|
||||
using System.ComponentModel;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
@ -8,9 +8,8 @@ namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("Логин сотрудника")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Номер телефона сотрудника")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Наименование")]
|
||||
public string NameOfCost { get; set; } = string.Empty;
|
||||
[DisplayName("Стоимость")]
|
||||
|
@ -11,26 +11,18 @@ namespace UniversityContracts.ViewModels
|
||||
public class EmployeeViewModel : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Фамилия")]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Имя")]
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Отчество")]
|
||||
public string? MiddleName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Должность")]
|
||||
public string Post { get; set; } = string.Empty;
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
public class OperationViewModel : IOperationModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("Номер телефона сотрудника")]
|
||||
public string EmployeePhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Стоимость")]
|
||||
public double Price { get; set; }
|
||||
[DisplayName("Вид операции")]
|
||||
public string Model { get; set; } = string.Empty;
|
||||
[DisplayName("Тип операции")]
|
||||
public string Mark { get; set; } = string.Empty;
|
||||
[JsonIgnore]
|
||||
public List<PurchaseViewModel> Purchases { get; set; } = new();
|
||||
public override string ToString()
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
foreach (var purchase in Purchases)
|
||||
{
|
||||
result.Append($"Операция вида {Model},Типа {Mark}, Купленная {purchase.DatePurchase.ToShortDateString()}," +
|
||||
$"в покупе c id: {purchase.Id}\n");
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -6,24 +6,24 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
namespace BankContracts.ViewModels
|
||||
{
|
||||
public class PaymentViewModel : IPaymentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ClassByPurchaseModelId { get; set; }
|
||||
public int OperationByPurchaseModelId { get; set; }
|
||||
[DisplayName("Стоимость")]
|
||||
public double FullPrice { get; set; }
|
||||
[DisplayName("Оплаченная стоимость")]
|
||||
public double PaidPrice { get; set; }
|
||||
public int ClassByPurchaseId { get; set; }
|
||||
public int OperationByPurchaseId { get; set; }
|
||||
[DisplayName("Дата оплаты")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public ClassByPurchaseModel ClassByPurchase { get; set; }
|
||||
public DateOnly Date { get; set; } = DateOnly.FromDateTime(DateTime.Now);
|
||||
public OperationByPurchaseModel OperationByPurchase { get; set; }
|
||||
|
||||
// Машины для отчета за период
|
||||
public ClassViewModel Operation { get; set; }
|
||||
public OperationViewModel Operation { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
using UniversityDataModels;
|
||||
using System.ComponentModel;
|
||||
using UniversityDataModels.Models;
|
||||
using System.Text;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
|
||||
namespace UniversityContracts.ViewModels
|
||||
{
|
||||
@ -10,30 +13,30 @@ namespace UniversityContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Логин клиента")]
|
||||
public string ClientLogin { get; set; } = string.Empty;
|
||||
public string ClientPhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("Дата Покупки")]
|
||||
public DateOnly DatePurchase { get; set; } = DateOnly.FromDateTime(DateTime.Now);
|
||||
public Dictionary<int, ClassByPurchaseModel> ClassModel { get; set; } = new();
|
||||
public Dictionary<int, OperationByPurchaseModel> OperationsModel { get; set; } = new();
|
||||
|
||||
public List<CostViewModel> CostViewModels { get; set; } = new();
|
||||
|
||||
public List<ClassViewModel> ClassViewModels { get; set; } = new();
|
||||
public List<OperationViewModel> OperationViewModels { get; set; } = new();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var result = new StringBuilder(
|
||||
$"Сделка, созданная {DatePurchase}, включает в себя операции:");
|
||||
for (int i = 0; i < ClassViewModels.Count; i++)
|
||||
for (int i = 0; i < OperationViewModels.Count; i++)
|
||||
{
|
||||
var car = ClassViewModels[i];
|
||||
var car = OperationViewModels[i];
|
||||
if (car == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
result.Append($"\n\t{i + 1}. {car.Time} {car.Name} стоимостью {car.Price}");
|
||||
result.Append($"\n\t{i + 1}. {car.Mark} {car.Model} стоимостью {car.Price}");
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
namespace UniversityDataModels.HelperInterfaces
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityDataModels.HelperInterfaces
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
@ -12,7 +13,7 @@ namespace UniversityDataModels
|
||||
string FirstName { get; }
|
||||
string LastName { get; }
|
||||
string? MiddleName { get; }
|
||||
string Login { get; }
|
||||
string PhoneNumber { get; }
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
@ -3,14 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
public interface IClassModel : IId
|
||||
public interface IOperationModel : IId
|
||||
{
|
||||
int EmployeeId { get; }
|
||||
string Name { get; }
|
||||
string Time { get; }
|
||||
string Model { get; }
|
||||
string Mark { get; }
|
||||
double Price { get; }
|
||||
}
|
||||
}
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
public interface IPaymentModel : IId
|
||||
{
|
||||
double PaidPrice { get; }
|
||||
DateTime DateCreate { get; }
|
||||
int ClassByPurchaseId { get; }
|
||||
DateOnly Date { get; }
|
||||
int OperationByPurchaseId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels
|
||||
{
|
||||
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UniversityDataModels.Models
|
||||
{
|
||||
public class ClassByPurchaseModel
|
||||
{
|
||||
public virtual int Id { get; set; }
|
||||
public virtual int ClassId { get; set; }
|
||||
public virtual int PurchaseId { get; set; }
|
||||
public virtual int CountClass { get; set; }
|
||||
}
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
|
||||
namespace UniversityDataModels.Models
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels.ProxyModels
|
||||
{
|
||||
public class CostByPurchaseModel : IId
|
||||
{
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.HelperInterfaces;
|
||||
|
||||
namespace UniversityDataModels.ProxyModels
|
||||
{
|
||||
public class OperationByPurchaseModel : IId
|
||||
{
|
||||
public virtual int Id { get; set; }
|
||||
public virtual int OperationId { get; set; }
|
||||
public virtual int PurchaseId { get; set; }
|
||||
public virtual int CountOperations { get; set; }
|
||||
}
|
||||
}
|
@ -7,17 +7,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -13,9 +13,9 @@ namespace UiversityDatabaseImplement.Implements
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.PhoneNumber) && string.IsNullOrEmpty(model.Password))
|
||||
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||
if (!model.Id.HasValue && (string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password)))
|
||||
if (!model.Id.HasValue && (string.IsNullOrEmpty(model.PhoneNumber) && !string.IsNullOrEmpty(model.Password)))
|
||||
throw new ArgumentException("Для нахождения соответствующего пользователя вместе с паролем нужен логин");
|
||||
}
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
@ -23,7 +23,7 @@ namespace UiversityDatabaseImplement.Implements
|
||||
CheckSearchModel(model);
|
||||
using var context = new UniversityDB();
|
||||
|
||||
return context.Clients.FirstOrDefault(x => x.Login.Equals(model.Login) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)))?.GetViewModel;
|
||||
return context.Clients.FirstOrDefault(x => x.PhoneNumber.Equals(model.PhoneNumber) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)))?.GetViewModel;
|
||||
}
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
|
@ -12,9 +12,9 @@ namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.PhoneNumber) && string.IsNullOrEmpty(model.Password))
|
||||
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||
if (!model.Id.HasValue && (string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password)))
|
||||
if (!model.Id.HasValue && (string.IsNullOrEmpty(model.PhoneNumber) && !string.IsNullOrEmpty(model.Password)))
|
||||
throw new ArgumentException("Для нахождения соответствующего пользователя вместе с паролем нужен логин");
|
||||
}
|
||||
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
|
||||
@ -23,7 +23,7 @@ namespace UniversityDatabaseImplement.Implements
|
||||
using var context = new UniversityDB();
|
||||
|
||||
return context.Employees
|
||||
.FirstOrDefault(x => x.Login.Equals(model.Login) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)))?.GetViewModel;
|
||||
.FirstOrDefault(x => x.PhoneNumber.Equals(model.PhoneNumber) && (string.IsNullOrEmpty(model.Password) || x.Password.Equals(model.Password)))?.GetViewModel;
|
||||
}
|
||||
public EmployeeViewModel? Insert(EmployeeBindingModel model)
|
||||
{
|
||||
|
@ -1,15 +1,20 @@
|
||||
using UniversityContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.StoragesContracts;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
public class ClassStorage : IClassStorage
|
||||
public class OperationStorage : IOperationStorage
|
||||
{
|
||||
private void CheckSearchModel(ClassSearchModel model)
|
||||
private void CheckSearchModel(OperationSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||
@ -17,20 +22,20 @@ namespace UniversityDatabaseImplement.Implements
|
||||
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||
}
|
||||
|
||||
public ClassViewModel? Delete(ClassBindingModel model)
|
||||
public OperationViewModel? Delete(OperationBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDB();
|
||||
var element = context.Classes.FirstOrDefault(x => x.Id == model.Id);
|
||||
var element = context.Operations.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Classes.Remove(element);
|
||||
context.Operations.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ClassViewModel? GetElement(ClassSearchModel model)
|
||||
public OperationViewModel? GetElement(OperationSearchModel model)
|
||||
{
|
||||
CheckSearchModel(model);
|
||||
if (!model.Id.HasValue)
|
||||
@ -38,12 +43,12 @@ namespace UniversityDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDB();
|
||||
return context.Classes
|
||||
return context.Operations
|
||||
.Include(x => x.Employee)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ClassViewModel> GetFilteredList(ClassSearchModel model)
|
||||
public List<OperationViewModel> GetFilteredList(OperationSearchModel model)
|
||||
{
|
||||
CheckSearchModel(model);
|
||||
if (model.Id.HasValue)
|
||||
@ -53,7 +58,7 @@ namespace UniversityDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new UniversityDB();
|
||||
|
||||
var query = context.Classes.Include(x => x.Employee);
|
||||
var query = context.Operations.Include(x => x.Employee);
|
||||
if (model.EmployeeId.HasValue)
|
||||
{
|
||||
|
||||
@ -74,31 +79,31 @@ namespace UniversityDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ClassViewModel> GetFullList()
|
||||
public List<OperationViewModel> GetFullList()
|
||||
{
|
||||
using var context = new UniversityDB();
|
||||
return context.Classes.Include(x => x.Employee)
|
||||
return context.Operations.Include(x => x.Employee)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ClassViewModel? Insert(ClassBindingModel model)
|
||||
public OperationViewModel? Insert(OperationBindingModel model)
|
||||
{
|
||||
var newOperation = Class.Create(model);
|
||||
var newOperation = Operation.Create(model);
|
||||
if (newOperation == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new UniversityDB();
|
||||
context.Classes.Add(newOperation);
|
||||
context.Operations.Add(newOperation);
|
||||
context.SaveChanges();
|
||||
return newOperation.GetViewModel;
|
||||
}
|
||||
|
||||
public ClassViewModel? Update(ClassBindingModel model)
|
||||
public OperationViewModel? Update(OperationBindingModel model)
|
||||
{
|
||||
using var context = new UniversityDB();
|
||||
var car = context.Classes.FirstOrDefault(x => x.Id == model.Id);
|
||||
var car = context.Operations.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (car == null)
|
||||
{
|
||||
return null;
|
||||
@ -108,4 +113,5 @@ namespace UniversityDatabaseImplement.Implements
|
||||
return car.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -11,8 +11,8 @@ namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
public class PaymentStorage : IPaymentStorage
|
||||
{
|
||||
private static IIncludableQueryable<Payment, Class?> Payments(UniversityDB context)
|
||||
=> context.Payments.Include(x => x.ClassByPurchase).ThenInclude(x => x.Class);
|
||||
private static IIncludableQueryable<Payment, Operation?> Payments(UniversityDB context)
|
||||
=> context.Payments.Include(x => x.OperationByPurchase).ThenInclude(x => x.Operation);
|
||||
|
||||
public List<PaymentViewModel> GetFullList()
|
||||
{
|
||||
@ -32,9 +32,9 @@ namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
throw new ArgumentException("Получена поисковая модель только с началом или концом периода");
|
||||
}
|
||||
if (!model.DateFrom.HasValue && !model.ClassId.HasValue)
|
||||
if (!model.DateFrom.HasValue && !model.OperationId.HasValue)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model.ClassId), "Получена поисковая модель без OperationId");
|
||||
throw new ArgumentNullException(nameof(model.OperationId), "Получена поисковая модель без OperationId");
|
||||
|
||||
}
|
||||
if (!model.DateFrom.HasValue && !model.PurchaseId.HasValue)
|
||||
@ -44,14 +44,14 @@ namespace UniversityDatabaseImplement.Implements
|
||||
using var context = new UniversityDB();
|
||||
if (model.DateFrom.HasValue)
|
||||
return Payments(context)
|
||||
.Where(x => x.DateCreate >= model.DateFrom.Value && x.DateCreate <= model.DateTo.Value)
|
||||
.Where(x => model.DateFrom.Value <= x.Date && x.Date <= model.DateTo.Value)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
||||
return Payments(context)
|
||||
.Where(x => x.ClassByPurchase != null &&
|
||||
x.ClassByPurchase.ClassId == model.ClassId &&
|
||||
x.ClassByPurchase.PurchaseId == model.PurchaseId)
|
||||
.Where(x => x.OperationByPurchase != null &&
|
||||
x.OperationByPurchase.OperationId == model.OperationId &&
|
||||
x.OperationByPurchase.PurchaseId == model.PurchaseId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace UniversityDatabaseImplement.Implements
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||
if (!model.Id.HasValue && !model.ClientId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && model.ClassesIds == null)
|
||||
if (!model.Id.HasValue && !model.ClientId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && model.OperationsIds == null)
|
||||
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||
if (model.DateFrom.HasValue != model.DateTo.HasValue)
|
||||
throw new ArgumentException($"Не указано начало {model.DateFrom} или конец {model.DateTo} периода для поиска по дате.");
|
||||
@ -34,7 +34,7 @@ namespace UniversityDatabaseImplement.Implements
|
||||
}
|
||||
|
||||
|
||||
public List<PaymentViewModel> GetPaymentsFromPurchaseAndOperation(PurchaseSearchModel modelPurchase, ClassSearchModel modelOperation)
|
||||
public List<PaymentViewModel> GetPaymentsFromPurchaseAndOperation(PurchaseSearchModel modelPurchase, OperationSearchModel modelOperation)
|
||||
{
|
||||
if (!modelPurchase.Id.HasValue)
|
||||
{
|
||||
@ -45,9 +45,9 @@ namespace UniversityDatabaseImplement.Implements
|
||||
throw new ArgumentNullException(nameof(modelOperation), "Получена поисковая модель без Id");
|
||||
}
|
||||
using var context = new UniversityDB();
|
||||
var carByPurchase = context.ClassByPurchases
|
||||
var carByPurchase = context.OperationByPurchases
|
||||
.Include(x => x.Payments)
|
||||
.FirstOrDefault(x => x.ClassId == modelOperation.Id && x.PurchaseId == modelPurchase.Id);
|
||||
.FirstOrDefault(x => x.OperationId == modelOperation.Id && x.PurchaseId == modelPurchase.Id);
|
||||
if (carByPurchase?.Payments == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
@ -94,16 +94,16 @@ namespace UniversityDatabaseImplement.Implements
|
||||
if (model.DateTo.HasValue)
|
||||
resultQuery = query
|
||||
.Include(x => x.Operations)
|
||||
.ThenInclude(x => x.Class)
|
||||
.ThenInclude(x => x.Operation)
|
||||
.Include(x => x.Costs)!
|
||||
.ThenInclude(x => x.Cost)
|
||||
.Where(x => model.DateFrom <= x.DatePurchase && x.DatePurchase <= model.DateTo);
|
||||
|
||||
else if (model.ClassesIds != null)
|
||||
else if (model.OperationsIds != null)
|
||||
resultQuery = query
|
||||
.Where(x => x.Operations.Any(x => model.ClassesIds.Contains(x.ClassId)))
|
||||
.Where(x => x.Operations.Any(x => model.OperationsIds.Contains(x.OperationId)))
|
||||
.Include(x => x.Operations)
|
||||
.ThenInclude(x => x.Class);
|
||||
.ThenInclude(x => x.Operation);
|
||||
|
||||
return resultQuery?
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -149,4 +149,5 @@ namespace UniversityDatabaseImplement.Implements
|
||||
return purchase.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
376
University/UniversityDatabaseImplement/Migrations/20240530182928_InitialCreate.Designer.cs
generated
Normal file
376
University/UniversityDatabaseImplement/Migrations/20240530182928_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,376 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using UniversityDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(UniversityDB))]
|
||||
[Migration("20240530182928_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Cost", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("NameOfCost")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Costs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.CostByPurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CostId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CostId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("CostByPurchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Post")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Operation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Mark")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Operations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.OperationByPurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountOperations")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OperationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OperationId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("OperationByPurchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Payment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<int>("OperationByPurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("PaidPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OperationByPurchaseId");
|
||||
|
||||
b.ToTable("Payments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("DatePurchase")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Cost", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Costs")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.CostByPurchase", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Cost", "Cost")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("CostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Costs")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cost");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Operation", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Operations")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.OperationByPurchase", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Operation", "Operation")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("OperationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Operations")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Operation");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Payment", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.OperationByPurchase", "OperationByPurchase")
|
||||
.WithMany("Payments")
|
||||
.HasForeignKey("OperationByPurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("OperationByPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Cost", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Costs");
|
||||
|
||||
b.Navigation("Operations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Operation", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.OperationByPurchase", b =>
|
||||
{
|
||||
b.Navigation("Payments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Costs");
|
||||
|
||||
b.Navigation("Operations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FirstName = table.Column<string>(type: "text", nullable: false),
|
||||
LastName = table.Column<string>(type: "text", nullable: false),
|
||||
MiddleName = table.Column<string>(type: "text", nullable: true),
|
||||
Address = table.Column<string>(type: "text", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Employees",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FirstName = table.Column<string>(type: "text", nullable: false),
|
||||
LastName = table.Column<string>(type: "text", nullable: false),
|
||||
MiddleName = table.Column<string>(type: "text", nullable: true),
|
||||
Post = table.Column<string>(type: "text", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Employees", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ClientId = table.Column<int>(type: "integer", nullable: false),
|
||||
DatePurchase = table.Column<DateOnly>(type: "date", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Costs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
EmployeeId = table.Column<int>(type: "integer", nullable: false),
|
||||
NameOfCost = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Costs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Costs_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Operations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
EmployeeId = table.Column<int>(type: "integer", nullable: false),
|
||||
Model = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false),
|
||||
Mark = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Operations", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Operations_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CostByPurchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CostId = table.Column<int>(type: "integer", nullable: false),
|
||||
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CostByPurchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_CostByPurchases_Costs_CostId",
|
||||
column: x => x.CostId,
|
||||
principalTable: "Costs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CostByPurchases_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OperationByPurchases",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OperationId = table.Column<int>(type: "integer", nullable: false),
|
||||
PurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
CountOperations = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OperationByPurchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OperationByPurchases_Operations_OperationId",
|
||||
column: x => x.OperationId,
|
||||
principalTable: "Operations",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OperationByPurchases_Purchases_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Payments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OperationByPurchaseId = table.Column<int>(type: "integer", nullable: false),
|
||||
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
PaidPrice = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Payments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Payments_OperationByPurchases_OperationByPurchaseId",
|
||||
column: x => x.OperationByPurchaseId,
|
||||
principalTable: "OperationByPurchases",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CostByPurchases_CostId",
|
||||
table: "CostByPurchases",
|
||||
column: "CostId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CostByPurchases_PurchaseId",
|
||||
table: "CostByPurchases",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Costs_EmployeeId",
|
||||
table: "Costs",
|
||||
column: "EmployeeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OperationByPurchases_OperationId",
|
||||
table: "OperationByPurchases",
|
||||
column: "OperationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OperationByPurchases_PurchaseId",
|
||||
table: "OperationByPurchases",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Operations_EmployeeId",
|
||||
table: "Operations",
|
||||
column: "EmployeeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Payments_OperationByPurchaseId",
|
||||
table: "Payments",
|
||||
column: "OperationByPurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ClientId",
|
||||
table: "Purchases",
|
||||
column: "ClientId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CostByPurchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Payments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Costs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OperationByPurchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Operations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchases");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Employees");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,374 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using UniversityDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace UniversityDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(UniversityDB))]
|
||||
partial class UniversityDBModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.0")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Cost", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("NameOfCost")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Costs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.CostByPurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CostId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CostId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("CostByPurchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("MiddleName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Post")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Operation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Mark")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("Operations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.OperationByPurchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountOperations")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("OperationId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OperationId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("OperationByPurchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Payment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<int>("OperationByPurchaseId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("PaidPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OperationByPurchaseId");
|
||||
|
||||
b.ToTable("Payments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("DatePurchase")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Cost", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Costs")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.CostByPurchase", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Cost", "Cost")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("CostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Costs")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cost");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Operation", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Employee", "Employee")
|
||||
.WithMany("Operations")
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.OperationByPurchase", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Operation", "Operation")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("OperationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Operations")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Operation");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Payment", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.OperationByPurchase", "OperationByPurchase")
|
||||
.WithMany("Payments")
|
||||
.HasForeignKey("OperationByPurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("OperationByPurchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("UniversityDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Cost", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Navigation("Costs");
|
||||
|
||||
b.Navigation("Operations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Operation", b =>
|
||||
{
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.OperationByPurchase", b =>
|
||||
{
|
||||
b.Navigation("Payments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("UniversityDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Costs");
|
||||
|
||||
b.Navigation("Operations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using UniversityDataModels.Models;
|
||||
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public class ClassByPurchase : ClassByPurchaseModel
|
||||
{
|
||||
[Required]
|
||||
public Class? Class { get; private set; }
|
||||
[Required]
|
||||
public Purchase? Purchase { get; private set; }
|
||||
[Required]
|
||||
public List<Payment>? Payments { get; private set; }
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.SearchModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDatabaseImplement.Implements;
|
||||
using UniversityDataModels;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public class Class : IClassModel
|
||||
{
|
||||
[Required]
|
||||
public int EmployeeId { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; private set; }
|
||||
[Required]
|
||||
public string Time { get; private set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public Employee? Employee { get; private set; }
|
||||
|
||||
[Required]
|
||||
public List<ClassByPurchase> Purchases { get; private set; } = new();
|
||||
|
||||
public static Class Create(ClassBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Class()
|
||||
{
|
||||
EmployeeId = model.EmployeeId,
|
||||
Name = model.Name,
|
||||
Price = model.Price,
|
||||
Time = model.Time,
|
||||
Id = model.Id,
|
||||
};
|
||||
}
|
||||
|
||||
public ClassViewModel GetViewModel => new()
|
||||
{
|
||||
EmployeeLogin = Employee?.Login??string.Empty,
|
||||
EmployeeId = EmployeeId,
|
||||
Name = Name,
|
||||
Price = Price,
|
||||
Time = Time,
|
||||
Id = Id,
|
||||
Purchases = Purchases.Select(x=>x.Purchase?.GetViewModel2).ToList(),
|
||||
};
|
||||
|
||||
public void Update(ClassBindingModel model)
|
||||
{
|
||||
Price = model.Price;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
[Required]
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Login { get; private set; } = string.Empty;
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
@ -36,7 +36,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
MiddleName = model.MiddleName,
|
||||
Login = model.Login,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Password = model.Password,
|
||||
Id = model.Id,
|
||||
Email = model.Email,
|
||||
@ -48,7 +48,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
FirstName = FirstName,
|
||||
LastName = LastName,
|
||||
MiddleName = MiddleName,
|
||||
Login =Login,
|
||||
PhoneNumber = PhoneNumber,
|
||||
Password = Password,
|
||||
Id = Id,
|
||||
Email = Email,
|
||||
|
@ -2,7 +2,7 @@
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
@ -41,6 +41,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
|
||||
public CostViewModel GetViewModel => new()
|
||||
{
|
||||
PhoneNumber = Employee?.PhoneNumber ?? string.Empty,
|
||||
PurchaseModels = PurchasesModels,
|
||||
EmployeeId = EmployeeId,
|
||||
NameOfCost = NameOfCost,
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
|
@ -16,13 +16,13 @@ namespace UniversityDatabaseImplement.Models
|
||||
[Required]
|
||||
public string Post { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Login { get; private set; } = string.Empty;
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public List<Class>? Class { get; private set; }
|
||||
public List<Operation>? Operations { get; private set; }
|
||||
[Required]
|
||||
public List<Cost>? Costs { get; private set; }
|
||||
|
||||
@ -37,9 +37,11 @@ namespace UniversityDatabaseImplement.Models
|
||||
FirstName = model.FirstName,
|
||||
LastName = model.LastName,
|
||||
MiddleName = model.MiddleName,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
Password = model.Password,
|
||||
Id = model.Id,
|
||||
Post = model.Post,
|
||||
Email = model.Email,
|
||||
};
|
||||
}
|
||||
|
||||
@ -48,9 +50,11 @@ namespace UniversityDatabaseImplement.Models
|
||||
FirstName = FirstName,
|
||||
LastName = LastName,
|
||||
MiddleName = MiddleName,
|
||||
PhoneNumber = PhoneNumber,
|
||||
Password = Password,
|
||||
Id = Id,
|
||||
Post = Post,
|
||||
Email = Email,
|
||||
};
|
||||
}
|
||||
}
|
64
University/UniversityDatabaseImplement/Models/Operation.cs
Normal file
64
University/UniversityDatabaseImplement/Models/Operation.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityContracts.BindingModels;
|
||||
using UniversityContracts.ViewModels;
|
||||
using UniversityDataModels;
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public class Operation : IOperationModel
|
||||
{
|
||||
[Required]
|
||||
public int EmployeeId { get; private set; }
|
||||
[Required]
|
||||
public string Model { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; private set; }
|
||||
[Required]
|
||||
public string Mark { get; private set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public Employee? Employee { get; private set; }
|
||||
|
||||
[Required]
|
||||
public List<OperationByPurchase> Purchases { get; private set; } = new();
|
||||
|
||||
public static Operation Create(OperationBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Operation()
|
||||
{
|
||||
EmployeeId = model.EmployeeId,
|
||||
Model = model.Model,
|
||||
Price = model.Price,
|
||||
Mark = model.Mark,
|
||||
Id = model.Id,
|
||||
};
|
||||
}
|
||||
|
||||
public OperationViewModel GetViewModel => new()
|
||||
{
|
||||
EmployeePhoneNumber = Employee?.PhoneNumber ?? string.Empty,
|
||||
EmployeeId = EmployeeId,
|
||||
Model = Model,
|
||||
Price = Price,
|
||||
Mark = Mark,
|
||||
Id = Id,
|
||||
Purchases = Purchases.Select(x => x.Purchase?.GetViewModel2).ToList(),
|
||||
};
|
||||
|
||||
public void Update(OperationBindingModel model)
|
||||
{
|
||||
Price = model.Price;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public class OperationByPurchase : OperationByPurchaseModel
|
||||
{
|
||||
[Required]
|
||||
public Operation? Operation { get; private set; }
|
||||
[Required]
|
||||
public Purchase? Purchase { get; private set; }
|
||||
[Required]
|
||||
public List<Payment>? Payments { get; private set; }
|
||||
}
|
||||
}
|
@ -10,10 +10,10 @@ namespace UniversityDatabaseImplement.Models
|
||||
public class Payment : IPaymentModel
|
||||
{
|
||||
[Required]
|
||||
public int ClassByPurchaseId { get; private set; }
|
||||
public int OperationByPurchaseId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; }
|
||||
public DateOnly Date { get; private set; }
|
||||
|
||||
[Required]
|
||||
public double PaidPrice { get; private set; }
|
||||
@ -21,7 +21,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public ClassByPurchase? ClassByPurchase { get; private set; }
|
||||
public OperationByPurchase? OperationByPurchase { get; private set; }
|
||||
|
||||
public static Payment Create(PaymentBindingModel model)
|
||||
{
|
||||
@ -32,21 +32,21 @@ namespace UniversityDatabaseImplement.Models
|
||||
return new Payment()
|
||||
{
|
||||
|
||||
DateCreate = model.DateCreate,
|
||||
Date = model.Date,
|
||||
PaidPrice = model.PaidPrice,
|
||||
Id = model.Id,
|
||||
ClassByPurchaseId = model.ClassByPurchaseId,
|
||||
OperationByPurchaseId = model.OperationByPurchaseId,
|
||||
};
|
||||
}
|
||||
public PaymentViewModel GetViewModel => new()
|
||||
{
|
||||
Operation = ClassByPurchase?.Class?.GetViewModel,
|
||||
ClassByPurchase = ClassByPurchase,
|
||||
FullPrice = ClassByPurchase?.Class?.Price ?? -1,
|
||||
DateCreate = DateCreate,
|
||||
Operation = OperationByPurchase?.Operation?.GetViewModel,
|
||||
OperationByPurchase = OperationByPurchase,
|
||||
FullPrice = OperationByPurchase?.Operation?.Price ?? -1,
|
||||
Date = Date,
|
||||
PaidPrice = PaidPrice,
|
||||
Id = Id,
|
||||
ClassByPurchaseId = ClassByPurchaseId,
|
||||
OperationByPurchaseId = OperationByPurchaseId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using UniversityDataModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq.Expressions;
|
||||
using UniversityDataModels.Models;
|
||||
using UniversityDataModels.ProxyModels;
|
||||
|
||||
|
||||
namespace UniversityDatabaseImplement.Models
|
||||
@ -13,16 +13,16 @@ namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
public int ClientId { get; private set; }
|
||||
public DateOnly DatePurchase { get; private set; }
|
||||
private Dictionary<int, ClassByPurchaseModel>? _cachedClasses;
|
||||
private Dictionary<int, OperationByPurchaseModel>? _cachedOperations;
|
||||
[NotMapped]
|
||||
public Dictionary<int, ClassByPurchaseModel> ClassModel => _cachedClasses ??=Operations.Select(x => (ClassByPurchaseModel)x).ToDictionary(x => x.ClassId, x => x);
|
||||
public Dictionary<int, OperationByPurchaseModel> OperationsModel => _cachedOperations ??= Operations.Select(x => (OperationByPurchaseModel)x).ToDictionary(x => x.OperationId, x => x);
|
||||
[NotMapped]
|
||||
public List<CostByPurchaseModel>? CostsModel => null;
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public Client? Client { get; private set; }
|
||||
[Required]
|
||||
public List<ClassByPurchase> Operations { get; private set; } = new();
|
||||
public List<OperationByPurchase> Operations { get; private set; } = new();
|
||||
[Required]
|
||||
public List<CostByPurchase> Costs { get; private set; } = new();
|
||||
|
||||
@ -43,27 +43,27 @@ namespace UniversityDatabaseImplement.Models
|
||||
|
||||
public PurchaseViewModel GetViewModel => new()
|
||||
{
|
||||
ClassModel = ClassModel,
|
||||
OperationsModel = OperationsModel,
|
||||
Id = Id,
|
||||
DatePurchase = DatePurchase,
|
||||
ClientId = ClientId,
|
||||
ClientLogin = Client?.Login ?? string.Empty,
|
||||
ClientPhoneNumber = Client?.PhoneNumber ?? string.Empty,
|
||||
|
||||
CostViewModels = Costs?
|
||||
.Select(x => x.Cost.GetViewModel)
|
||||
.ToList() ?? new(),
|
||||
ClassViewModels = Operations?
|
||||
.Select(x => x.Class?.GetViewModel)
|
||||
OperationViewModels = Operations?
|
||||
.Select(x => x.Operation?.GetViewModel)
|
||||
.ToList() ?? new()
|
||||
};
|
||||
|
||||
public PurchaseViewModel GetViewModel2 => new()
|
||||
{
|
||||
ClassModel = ClassModel,
|
||||
OperationsModel = OperationsModel,
|
||||
Id = Id,
|
||||
DatePurchase = DatePurchase,
|
||||
ClientId = ClientId,
|
||||
ClientLogin = Client?.Login ?? string.Empty,
|
||||
ClientPhoneNumber = Client?.PhoneNumber ?? string.Empty,
|
||||
|
||||
CostViewModels = Costs?
|
||||
.Select(x => x.Cost.GetViewModel)
|
||||
@ -72,14 +72,14 @@ namespace UniversityDatabaseImplement.Models
|
||||
|
||||
public void UpdateOperations(UniversityDB context, PurchaseBindingModel model)
|
||||
{
|
||||
var oldOperations = context.ClassByPurchases.Where(x => x.PurchaseId == model.Id).ToDictionary(x => x.ClassId, x => x);
|
||||
var newOperations = model.ClassModel.ToDictionary(
|
||||
var oldOperations = context.OperationByPurchases.Where(x => x.PurchaseId == model.Id).ToDictionary(x => x.OperationId, x => x);
|
||||
var newOperations = model.OperationsModel.ToDictionary(
|
||||
x => x.Key,
|
||||
x => new ClassByPurchase()
|
||||
x => new OperationByPurchase()
|
||||
{
|
||||
ClassId = x.Key,
|
||||
OperationId = x.Key,
|
||||
PurchaseId = Id,
|
||||
CountClass = x.Value.CountClass
|
||||
CountOperations = x.Value.CountOperations
|
||||
}
|
||||
);
|
||||
|
||||
@ -88,9 +88,9 @@ namespace UniversityDatabaseImplement.Models
|
||||
oldOperations
|
||||
.Where(x => newOperations.ContainsKey(x.Key))
|
||||
.Select(x => x.Value).ToList()
|
||||
.ForEach(x => x.CountClass = newOperations[x.ClassId].CountClass);
|
||||
.ForEach(x => x.CountOperations = newOperations[x.OperationId].CountOperations);
|
||||
context.SaveChanges();
|
||||
_cachedClasses = null;
|
||||
_cachedOperations = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,12 @@ namespace UniversityDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=University;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseNpgsql(@"
|
||||
Host=localhost;
|
||||
Port=5432;
|
||||
Database=UniversityFullNew;
|
||||
Username=postgres;
|
||||
Password=55256636a;");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
@ -20,8 +25,8 @@ namespace UniversityDatabaseImplement
|
||||
public virtual DbSet<Cost> Costs { set; get; }
|
||||
public virtual DbSet<CostByPurchase> CostByPurchases { set; get; }
|
||||
public virtual DbSet<Employee> Employees { set; get; }
|
||||
public virtual DbSet<Class> Classes { set; get; }
|
||||
public virtual DbSet<ClassByPurchase> ClassByPurchases { set; get; }
|
||||
public virtual DbSet<Operation> Operations { set; get; }
|
||||
public virtual DbSet<OperationByPurchase> OperationByPurchases { set; get; }
|
||||
public virtual DbSet<Payment> Payments { set; get; }
|
||||
public virtual DbSet<Purchase> Purchases { set; get; }
|
||||
}
|
||||
|
@ -12,13 +12,10 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
@ -15,7 +15,7 @@ builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddSession(); // Äîáàâëÿåì ñåññèþ äëÿ àâòîðèçàöèè
|
||||
|
||||
builder.Services.AddTransient<IEmployeeLogic, EmployeeLogic>();
|
||||
builder.Services.AddTransient<IClassLogic, ClassLogic>();
|
||||
builder.Services.AddTransient<IOperationLogic, OperationLogic>();
|
||||
builder.Services.AddTransient<ICostLogic, CostLogic>();
|
||||
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
|
||||
builder.Services.AddTransient<IPaymentLogic, PaymentLogic>();
|
||||
@ -26,7 +26,7 @@ builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
builder.Services.AddTransient<IEmployeeStorage, EmployeeStorage>();
|
||||
builder.Services.AddTransient<IClassStorage, ClassStorage>();
|
||||
builder.Services.AddTransient<IOperationStorage, OperationStorage>();
|
||||
builder.Services.AddTransient<ICostStorage, CostStorage>();
|
||||
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
|
||||
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
|
||||
|
@ -7,17 +7,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user