add searchmodels, edit storages

This commit is contained in:
revengel66 2024-07-24 21:04:21 +03:00
parent 9fb4943f9b
commit f64f29a84b
36 changed files with 248 additions and 118 deletions

View File

@ -4,10 +4,10 @@ namespace BeautySalonContracts.BindingModels
public class ClientBindingModel
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
public string? Phone { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
}
}

View File

@ -4,7 +4,7 @@ namespace BeautySalonContracts.BindingModels
public class CosmeticBindingModel
{
public int Id { get; set; }
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
}
}

View File

@ -5,10 +5,10 @@ namespace BeautySalonContracts.BindingModels
public class EmployeeBindingModel
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
public string? Phone { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
}
}

View File

@ -4,8 +4,8 @@ namespace BeautySalonContracts.BindingModels
public class ProcedureBindingModel
{
public int Id { get; set; }
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public string? FIO_Master { get; set; }
public string FIO_Master { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,9 @@

namespace BeautySalonContracts.SearchModels
{
public class ClientSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
}
}

View File

@ -0,0 +1,9 @@

namespace BeautySalonContracts.SearchModels
{
public class CosmeticSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,8 @@

namespace BeautySalonContracts.SearchModels
{
public class DistributionSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,10 @@

namespace BeautySalonContracts.SearchModels
{
public class EmployeeSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
}
}

View File

@ -0,0 +1,9 @@

namespace BeautySalonContracts.SearchModels
{
public class ProcedureSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,8 @@

namespace BeautySalonContracts.SearchModels
{
public class PurchaseSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,8 @@

namespace BeautySalonContracts.SearchModels
{
public class ReceiptSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,8 @@

namespace BeautySalonContracts.SearchModels
{
public class VisitSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
@ -6,8 +7,8 @@ namespace BeautySalonContracts.StorageContracts
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientBindingModel model);
ClientViewModel GetElement(ClientBindingModel model);
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel GetElement(ClientSearchModel model);
ClientViewModel Insert(ClientBindingModel model);
ClientViewModel Update(ClientBindingModel model);
ClientViewModel Deleted(ClientBindingModel model);

View File

@ -1,5 +1,6 @@

using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
@ -8,11 +9,11 @@ namespace BeautySalonContracts.StorageContracts
public interface ICosmeticStorage
{
List<CosmeticViewModel> GetFullList();
List<CosmeticViewModel> GetFilteredList(CosmeticBindingModel model);
CosmeticViewModel GetElement(CosmeticBindingModel model);
CosmeticViewModel Insert(CosmeticBindingModel model);
CosmeticViewModel Update(CosmeticBindingModel model);
CosmeticViewModel Deleted(CosmeticBindingModel model);
List<CosmeticViewModel> GetFilteredList(CosmeticSearchModel model);
CosmeticViewModel? GetElement(CosmeticSearchModel model);
CosmeticViewModel? Insert(CosmeticBindingModel model);
CosmeticViewModel? Update(CosmeticBindingModel model);
CosmeticViewModel? Deleted(CosmeticBindingModel model);
}
}

View File

@ -1,5 +1,6 @@

using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
@ -7,8 +8,8 @@ namespace BeautySalonContracts.StorageContracts
public interface IDistributionStorage
{
List<DistributionViewModel> GetFullList();
List<DistributionViewModel> GetFilteredList(DistributionBindingModel model);
DistributionViewModel GetElement(DistributionBindingModel model);
List<DistributionViewModel> GetFilteredList(DistributionSearchModel model);
DistributionViewModel GetElement(DistributionSearchModel model);
DistributionViewModel Insert(DistributionBindingModel model);
DistributionViewModel Update(DistributionBindingModel model);
DistributionViewModel Deleted(DistributionBindingModel model);

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
@ -6,8 +7,8 @@ namespace BeautySalonContracts.StorageContracts
public interface IEmployeeStorage
{
List<EmployeeViewModel> GetFullList();
List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model);
EmployeeViewModel GetElement(EmployeeBindingModel model);
List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model);
EmployeeViewModel GetElement(EmployeeSearchModel model);
EmployeeViewModel Insert(EmployeeBindingModel model);
EmployeeViewModel Update(EmployeeBindingModel model);
EmployeeViewModel Deleted(EmployeeBindingModel model);

View File

@ -1,12 +1,13 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
{
public interface IProcedureStorage
{
List<ProcedureViewModel> GetFullList();
List<ProcedureViewModel> GetFilteredList(ProcedureBindingModel model);
ProcedureViewModel GetElement(ProcedureBindingModel model);
List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model);
ProcedureViewModel GetElement(ProcedureSearchModel model);
ProcedureViewModel Insert(ProcedureBindingModel model);
ProcedureViewModel Update(ProcedureBindingModel model);
ProcedureViewModel Deleted(ProcedureBindingModel model);

View File

@ -1,5 +1,6 @@

using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
@ -7,8 +8,8 @@ namespace BeautySalonContracts.StorageContracts
public interface IPurchaseStorage
{
List<PurchaseViewModel> GetFullList();
List<PurchaseViewModel> GetFilteredList(PurchaseBindingModel model);
PurchaseViewModel GetElement(PurchaseBindingModel model);
List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model);
PurchaseViewModel GetElement(PurchaseSearchModel model);
PurchaseViewModel Insert(PurchaseBindingModel model);
PurchaseViewModel Update(PurchaseBindingModel model);
PurchaseViewModel Deleted(PurchaseBindingModel model);

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
@ -6,8 +7,8 @@ namespace BeautySalonContracts.StorageContracts
public interface IReceiptStorage
{
List<ReceiptViewModel> GetFullList();
List<ReceiptViewModel> GetFilteredList(ReceiptBindingModel model);
ReceiptViewModel GetElement(ReceiptBindingModel model);
List<ReceiptViewModel> GetFilteredList(ReceiptSearchModel model);
ReceiptViewModel GetElement(ReceiptSearchModel model);
ReceiptViewModel Insert(ReceiptBindingModel model);
ReceiptViewModel Update(ReceiptBindingModel model);
ReceiptViewModel Deleted(ReceiptBindingModel model);

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
namespace BeautySalonContracts.StorageContracts
@ -6,8 +7,8 @@ namespace BeautySalonContracts.StorageContracts
public interface IVisitStorage
{
List<VisitViewModel> GetFullList();
List<VisitViewModel> GetFilteredList(VisitBindingModel model);
VisitViewModel GetElement(VisitBindingModel model);
List<VisitViewModel> GetFilteredList(VisitSearchModel model);
VisitViewModel GetElement(VisitSearchModel model);
VisitViewModel Insert(VisitBindingModel model);
VisitViewModel Update(VisitBindingModel model);
VisitViewModel Deleted(VisitBindingModel model);

View File

@ -7,14 +7,14 @@ namespace BeautySalonContracts.ViewModels
{
public int Id { get; set; }
[DisplayName("Имя")]
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string? Surname { get; set; }
public string Surname { get; set; } = string.Empty;
[DisplayName("Логин")]
public string? Login { get; set; }
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string? Password { get; set; }
public string Password { get; set; } = string.Empty;
[DisplayName("Телефон")]
public string? Phone { get; set; }
public string Phone { get; set; } = string.Empty;
}
}

View File

@ -7,7 +7,7 @@ namespace BeautySalonContracts.ViewModels
{
public int Id { get; set; }
[DisplayName("Название")]
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
}

View File

@ -8,14 +8,14 @@ namespace BeautySalonContracts.ViewModels
{
public int Id { get; set; }
[DisplayName("Имя")]
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
[DisplayName("Фамилия")]
public string? Surname { get; set; }
public string Surname { get; set; } = string.Empty;
[DisplayName("Логин")]
public string? Login { get; set; }
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string? Password { get; set; }
public string Password { get; set; } = string.Empty;
[DisplayName("Телефон")]
public string? Phone { get; set; }
public string Phone { get; set; } = string.Empty;
}
}

View File

@ -7,10 +7,10 @@ namespace BeautySalonContracts.ViewModels
{
public int Id { get; set; }
[DisplayName("Название")]
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
[DisplayName("ФИО мастера")]
public string? FIO_Master { get; set; }
public string FIO_Master { get; set; } = string.Empty;
}
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -12,12 +13,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public ClientViewModel GetElement(ClientBindingModel model)
public ClientViewModel GetElement(ClientSearchModel model)
{
throw new NotImplementedException();
}
public List<ClientViewModel> GetFilteredList(ClientBindingModel model)
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -1,6 +1,10 @@
using BeautySalonContracts.BindingModels;
using System.ComponentModel;
using System.Reflection;
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
using BeautySalonDatabaseImplement.Models;
using BeautySalonListImplement;
namespace BeautySalonDatabaseImplement.Implements
@ -12,33 +16,75 @@ namespace BeautySalonDatabaseImplement.Implements
{
_source = DataListSingleton.GetInstance();
}
public CosmeticViewModel GetElement(CosmeticBindingModel model)
public List<CosmeticViewModel> GetFilteredList(CosmeticSearchModel model)
{
foreach(var cosmetic in _source.Cosmetics)
var result = new List<CosmeticViewModel>();
if (string.IsNullOrEmpty(model.Name))
{
return result;
}
public List<CosmeticViewModel> GetFilteredList(CosmeticBindingModel model)
foreach (var cosmetic in _source.Cosmetics)
{
throw new NotImplementedException();
if (cosmetic.Name.Contains(model.Name))
{
result.Add(cosmetic.GetViewModel);
}
}
return result;
}
public List<CosmeticViewModel> GetFullList()
{
throw new NotImplementedException();
var result = new List<CosmeticViewModel>();
foreach (var cosmetic in _source.Cosmetics)
{
result.Add(cosmetic.GetViewModel);
}
return result;
}
public CosmeticViewModel? GetElement(CosmeticSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return null;
}
foreach(var cosmetic in _source.Cosmetics)
{
if ((!string.IsNullOrEmpty(model.Name) && cosmetic.Name == model.Name) || (cosmetic.Id == model.Id))
{
return cosmetic.GetViewModel;
}
}
return null;
}
public CosmeticViewModel Insert(CosmeticBindingModel model)
public CosmeticViewModel? Insert(CosmeticBindingModel model)
{
model.Id = 1;
foreach (var cosmetic in _source.Cosmetics)
{
if (model.Id == cosmetic.Id)
{
model.Id = cosmetic.Id + 1;
}
}
var newCosmetic = Cosmetic.Create(model);
if (newCosmetic == null)
{
return null;
}
_source.Cosmetics.Add(newCosmetic);
return newComponent.GetViewModel;
}
public CosmeticViewModel? Update(CosmeticBindingModel model)
{
throw new NotImplementedException();
}
public CosmeticViewModel Update(CosmeticBindingModel model)
{
throw new NotImplementedException();
}
public CosmeticViewModel Deleted(CosmeticBindingModel model)
public CosmeticViewModel? Deleted(CosmeticBindingModel model)
{
throw new NotImplementedException();
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -11,12 +12,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public DistributionViewModel GetElement(DistributionBindingModel model)
public DistributionViewModel GetElement(DistributionSearchModel model)
{
throw new NotImplementedException();
}
public List<DistributionViewModel> GetFilteredList(DistributionBindingModel model)
public List<DistributionViewModel> GetFilteredList(DistributionSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -11,12 +12,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public EmployeeViewModel GetElement(EmployeeBindingModel model)
public EmployeeViewModel GetElement(EmployeeSearchModel model)
{
throw new NotImplementedException();
}
public List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -11,12 +12,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public ProcedureViewModel GetElement(ProcedureBindingModel model)
public ProcedureViewModel GetElement(ProcedureSearchModel model)
{
throw new NotImplementedException();
}
public List<ProcedureViewModel> GetFilteredList(ProcedureBindingModel model)
public List<ProcedureViewModel> GetFilteredList(ProcedureSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -11,12 +12,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public PurchaseViewModel GetElement(PurchaseBindingModel model)
public PurchaseViewModel GetElement(PurchaseSearchModel model)
{
throw new NotImplementedException();
}
public List<PurchaseViewModel> GetFilteredList(PurchaseBindingModel model)
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -1,4 +1,5 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -11,12 +12,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public ReceiptViewModel GetElement(ReceiptBindingModel model)
public ReceiptViewModel GetElement(ReceiptSearchModel model)
{
throw new NotImplementedException();
}
public List<ReceiptViewModel> GetFilteredList(ReceiptBindingModel model)
public List<ReceiptViewModel> GetFilteredList(ReceiptSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -1,5 +1,6 @@

using BeautySalonContracts.BindingModels;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.StorageContracts;
using BeautySalonContracts.ViewModels;
@ -12,12 +13,12 @@ namespace BeautySalonDatabaseImplement.Implements
throw new NotImplementedException();
}
public VisitViewModel GetElement(VisitBindingModel model)
public VisitViewModel GetElement(VisitSearchModel model)
{
throw new NotImplementedException();
}
public List<VisitViewModel> GetFilteredList(VisitBindingModel model)
public List<VisitViewModel> GetFilteredList(VisitSearchModel model)
{
throw new NotImplementedException();
}

View File

@ -8,11 +8,11 @@ namespace BeautySalonDatabaseImplement.Models
public class Client
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
public string? Phone { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
public static Client? Create(ClientBindingModel model)
{

View File

@ -7,7 +7,7 @@ namespace BeautySalonDatabaseImplement.Models
public class Cosmetic
{
public int Id { get; set; }
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public static Cosmetic? Create(CosmeticBindingModel model)

View File

@ -7,11 +7,11 @@ namespace BeautySalonDatabaseImplement.Models
public class Employee
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public string? Login { get; set; }
public string? Password { get; set; }
public string? Phone { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
public static Employee? Create(EmployeeBindingModel model)
{
if (model == null)

View File

@ -8,9 +8,9 @@ namespace BeautySalonDatabaseImplement.Models
public class Procedure
{
public int Id { get; set; }
public string? Name { get; set; }
public string Name { get; set; } = string.Empty;
public double Price { get; set; }
public string? FIO_Master { get; set; }
public string FIO_Master { get; set; } = string.Empty;
public static Procedure? Create(ProcedureBindingModel model)
{
if (model == null)