Исправление ошибок
This commit is contained in:
parent
a67f3562c3
commit
84e7d8438d
@ -7,25 +7,25 @@ using UniversityDatabaseImplement.Models;
|
||||
|
||||
namespace UiversityDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClassStorage
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
private void CheckSearchModel(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
if (model == null)
|
||||
throw new ArgumentNullException("Передаваемая модель для поиска равна нулю", nameof(model));
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.PhoneNumber) && string.IsNullOrEmpty(model.Password))
|
||||
throw new ArgumentException("Все передаваемые поля поисковой модели оказались пусты или равны null");
|
||||
if (!model.Id.HasValue && (string.IsNullOrEmpty(model.PhoneNumber) && !string.IsNullOrEmpty(model.Password)))
|
||||
throw new ArgumentException("Для нахождения соответствующего пользователя вместе с паролем нужен логин");
|
||||
}
|
||||
public ClassViewModel? GetElement(ClientSearchModel model)
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
CheckSearchModel(model);
|
||||
using var context = new UniversityDB();
|
||||
|
||||
return context.Clients.FirstOrDefault(x => (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 ClassViewModel? Insert(ClientBindingModel model)
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public DateOnly DatePurchase { get; private set; }
|
||||
private Dictionary<int, ClassByPurchaseModel>? _cachedOperations;
|
||||
[NotMapped]
|
||||
public Dictionary<int, ClassByPurchaseModel> ClassModel => _cachedOperations ??= Class.Select (x => (ClassByPurchaseModel)x).ToDictionary(x => x.ClassId, x => x);
|
||||
public Dictionary<int, ClassByPurchaseModel> ClassModel => _cachedOperations ??= Operations.Select (x => (ClassByPurchaseModel)x).ToDictionary(x => x.ClassId, x => x);
|
||||
[NotMapped]
|
||||
public List<CostByPurchaseModel>? CostsModel => null;
|
||||
public int Id { get; private set; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user