end CosmeticStorage

This commit is contained in:
revengel66 2024-07-25 18:44:30 +04:00
parent f64f29a84b
commit a750157cb8
25 changed files with 81 additions and 64 deletions

View File

@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18 VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonView", "BeautySalonView\BeautySalonView.csproj", "{3DA370D1-A702-425A-A7DE-D558514373A6}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonView", "BeautySalonView\BeautySalonView.csproj", "{3DA370D1-A702-425A-A7DE-D558514373A6}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonContracts", "BeautySalonContracts\BeautySalonContracts.csproj", "{96010EED-D9BD-4238-941F-1D93459E5A63}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonContracts", "BeautySalonContracts\BeautySalonContracts.csproj", "{96010EED-D9BD-4238-941F-1D93459E5A63}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonBusinessLogic", "BeautySalonBusinessLogic\BeautySalonBusinessLogic.csproj", "{8E38BF54-E62B-43B6-970A-57D949CBF5A9}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonBusinessLogic", "BeautySalonBusinessLogic\BeautySalonBusinessLogic.csproj", "{8E38BF54-E62B-43B6-970A-57D949CBF5A9}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonDatabaseImplement", "BeautySalonDatabaseImplement\BeautySalonDatabaseImplement.csproj", "{96FDD17C-1CDF-42F1-9A16-D6A90285F5DA}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeautySalonListImplement", "BeautySalonDatabaseImplement\BeautySalonListImplement.csproj", "{96FDD17C-1CDF-42F1-9A16-D6A90285F5DA}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -11,6 +11,6 @@ namespace BeautySalonContracts.StorageContracts
ClientViewModel GetElement(ClientSearchModel model); ClientViewModel GetElement(ClientSearchModel model);
ClientViewModel Insert(ClientBindingModel model); ClientViewModel Insert(ClientBindingModel model);
ClientViewModel Update(ClientBindingModel model); ClientViewModel Update(ClientBindingModel model);
ClientViewModel Deleted(ClientBindingModel model); ClientViewModel Delete(ClientBindingModel model);
} }
} }

View File

@ -13,7 +13,7 @@ namespace BeautySalonContracts.StorageContracts
CosmeticViewModel? GetElement(CosmeticSearchModel model); CosmeticViewModel? GetElement(CosmeticSearchModel model);
CosmeticViewModel? Insert(CosmeticBindingModel model); CosmeticViewModel? Insert(CosmeticBindingModel model);
CosmeticViewModel? Update(CosmeticBindingModel model); CosmeticViewModel? Update(CosmeticBindingModel model);
CosmeticViewModel? Deleted(CosmeticBindingModel model); CosmeticViewModel? Delete(CosmeticBindingModel model);
} }
} }

View File

@ -12,6 +12,6 @@ namespace BeautySalonContracts.StorageContracts
DistributionViewModel GetElement(DistributionSearchModel model); DistributionViewModel GetElement(DistributionSearchModel model);
DistributionViewModel Insert(DistributionBindingModel model); DistributionViewModel Insert(DistributionBindingModel model);
DistributionViewModel Update(DistributionBindingModel model); DistributionViewModel Update(DistributionBindingModel model);
DistributionViewModel Deleted(DistributionBindingModel model); DistributionViewModel Delete(DistributionBindingModel model);
} }
} }

View File

@ -11,6 +11,6 @@ namespace BeautySalonContracts.StorageContracts
EmployeeViewModel GetElement(EmployeeSearchModel model); EmployeeViewModel GetElement(EmployeeSearchModel model);
EmployeeViewModel Insert(EmployeeBindingModel model); EmployeeViewModel Insert(EmployeeBindingModel model);
EmployeeViewModel Update(EmployeeBindingModel model); EmployeeViewModel Update(EmployeeBindingModel model);
EmployeeViewModel Deleted(EmployeeBindingModel model); EmployeeViewModel Delete(EmployeeBindingModel model);
} }
} }

View File

@ -10,6 +10,6 @@ namespace BeautySalonContracts.StorageContracts
ProcedureViewModel GetElement(ProcedureSearchModel model); ProcedureViewModel GetElement(ProcedureSearchModel model);
ProcedureViewModel Insert(ProcedureBindingModel model); ProcedureViewModel Insert(ProcedureBindingModel model);
ProcedureViewModel Update(ProcedureBindingModel model); ProcedureViewModel Update(ProcedureBindingModel model);
ProcedureViewModel Deleted(ProcedureBindingModel model); ProcedureViewModel Delete(ProcedureBindingModel model);
} }
} }

View File

@ -12,6 +12,6 @@ namespace BeautySalonContracts.StorageContracts
PurchaseViewModel GetElement(PurchaseSearchModel model); PurchaseViewModel GetElement(PurchaseSearchModel model);
PurchaseViewModel Insert(PurchaseBindingModel model); PurchaseViewModel Insert(PurchaseBindingModel model);
PurchaseViewModel Update(PurchaseBindingModel model); PurchaseViewModel Update(PurchaseBindingModel model);
PurchaseViewModel Deleted(PurchaseBindingModel model); PurchaseViewModel Delete(PurchaseBindingModel model);
} }
} }

View File

@ -11,6 +11,6 @@ namespace BeautySalonContracts.StorageContracts
ReceiptViewModel GetElement(ReceiptSearchModel model); ReceiptViewModel GetElement(ReceiptSearchModel model);
ReceiptViewModel Insert(ReceiptBindingModel model); ReceiptViewModel Insert(ReceiptBindingModel model);
ReceiptViewModel Update(ReceiptBindingModel model); ReceiptViewModel Update(ReceiptBindingModel model);
ReceiptViewModel Deleted(ReceiptBindingModel model); ReceiptViewModel Delete(ReceiptBindingModel model);
} }
} }

View File

@ -11,6 +11,6 @@ namespace BeautySalonContracts.StorageContracts
VisitViewModel GetElement(VisitSearchModel model); VisitViewModel GetElement(VisitSearchModel model);
VisitViewModel Insert(VisitBindingModel model); VisitViewModel Insert(VisitBindingModel model);
VisitViewModel Update(VisitBindingModel model); VisitViewModel Update(VisitBindingModel model);
VisitViewModel Deleted(VisitBindingModel model); VisitViewModel Delete(VisitBindingModel model);
} }
} }

View File

@ -8,7 +8,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class ClientStorage : IClientStorage internal class ClientStorage : IClientStorage
{ {
public ClientViewModel Deleted(ClientBindingModel model) public ClientViewModel Delete(ClientBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -45,13 +45,13 @@ namespace BeautySalonDatabaseImplement.Implements
} }
public CosmeticViewModel? GetElement(CosmeticSearchModel model) public CosmeticViewModel? GetElement(CosmeticSearchModel model)
{ {
if (string.IsNullOrEmpty(model.Name)) if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{ {
return null; return null;
} }
foreach(var cosmetic in _source.Cosmetics) foreach(var cosmetic in _source.Cosmetics)
{ {
if ((!string.IsNullOrEmpty(model.Name) && cosmetic.Name == model.Name) || (cosmetic.Id == model.Id)) if ((!string.IsNullOrEmpty(model.Name) && cosmetic.Name == model.Name) || (cosmetic.Id == model.Id && model.Id.HasValue))
{ {
return cosmetic.GetViewModel; return cosmetic.GetViewModel;
} }
@ -76,17 +76,34 @@ namespace BeautySalonDatabaseImplement.Implements
} }
_source.Cosmetics.Add(newCosmetic); _source.Cosmetics.Add(newCosmetic);
return newComponent.GetViewModel; return newCosmetic.GetViewModel;
} }
public CosmeticViewModel? Update(CosmeticBindingModel model) public CosmeticViewModel? Update(CosmeticBindingModel model)
{ {
throw new NotImplementedException(); foreach (var cosmetic in _source.Cosmetics)
}
public CosmeticViewModel? Deleted(CosmeticBindingModel model)
{ {
throw new NotImplementedException(); if (cosmetic.Id == model.Id)
{
cosmetic.Update(model);
return cosmetic.GetViewModel;
}
}
return null;
}
public CosmeticViewModel? Delete(CosmeticBindingModel model)
{
for (int i = 0; i < _source.Cosmetics.Count; ++i)
{
if (_source.Cosmetics[i].Id == model.Id)
{
var deleted = _source.Cosmetics[i];
_source.Cosmetics.RemoveAt(i);
return deleted.GetViewModel;
}
}
return null;
} }
} }

View File

@ -7,7 +7,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class DistributionStorage : IDistributionStorage internal class DistributionStorage : IDistributionStorage
{ {
public DistributionViewModel Deleted(DistributionBindingModel model) public DistributionViewModel Delete(DistributionBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -7,7 +7,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class EmployeeStorage : IEmployeeStorage internal class EmployeeStorage : IEmployeeStorage
{ {
public EmployeeViewModel Deleted(EmployeeBindingModel model) public EmployeeViewModel Delete(EmployeeBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -7,7 +7,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class ProcedureStorage : IProcedureStorage internal class ProcedureStorage : IProcedureStorage
{ {
public ProcedureViewModel Deleted(ProcedureBindingModel model) public ProcedureViewModel Delete(ProcedureBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -7,7 +7,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class PurchaseStorage : IPurchaseStorage internal class PurchaseStorage : IPurchaseStorage
{ {
public PurchaseViewModel Deleted(PurchaseBindingModel model) public PurchaseViewModel Delete(PurchaseBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -7,7 +7,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class ReceiptStorage : IReceiptStorage internal class ReceiptStorage : IReceiptStorage
{ {
public ReceiptViewModel Deleted(ReceiptBindingModel model) public ReceiptViewModel Delete(ReceiptBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -8,7 +8,7 @@ namespace BeautySalonDatabaseImplement.Implements
{ {
internal class VisitStorage : IVisitStorage internal class VisitStorage : IVisitStorage
{ {
public VisitViewModel Deleted(VisitBindingModel model) public VisitViewModel Delete(VisitBindingModel model)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -5,14 +5,14 @@ using System.Diagnostics;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Client internal class Client
{ {
public int Id { get; set; } public int Id { get; private set; }
public string Name { get; set; } = string.Empty; public string Name { get; private set; } = string.Empty;
public string Surname { get; set; } = string.Empty; public string Surname { get; private set; } = string.Empty;
public string Login { get; set; } = string.Empty; public string Login { get; private set; } = string.Empty;
public string Password { get; set; } = string.Empty; public string Password { get; private set; } = string.Empty;
public string Phone { get; set; } = string.Empty; public string Phone { get; private set; } = string.Empty;
public static Client? Create(ClientBindingModel model) public static Client? Create(ClientBindingModel model)
{ {

View File

@ -4,11 +4,11 @@ using BeautySalonContracts.ViewModels;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Cosmetic internal class Cosmetic
{ {
public int Id { get; set; } public int Id { get; private set; }
public string Name { get; set; } = string.Empty; public string Name { get; private set; } = string.Empty;
public double Price { get; set; } public double Price { get; private set; }
public static Cosmetic? Create(CosmeticBindingModel model) public static Cosmetic? Create(CosmeticBindingModel model)
{ {

View File

@ -7,11 +7,11 @@ using System.Xml.Linq;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Distribution internal class Distribution
{ {
public int Id { get; set; } public int Id { get; private set; }
public DateTime Date { get; set; } public DateTime Date { get; private set; }
public double Sum { get; set; } public double Sum { get; private set; }
public static Distribution? Create(DistributionBindingModel model) public static Distribution? Create(DistributionBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -4,14 +4,14 @@ using BeautySalonContracts.ViewModels;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Employee internal class Employee
{ {
public int Id { get; set; } public int Id { get; private set; }
public string Name { get; set; } = string.Empty; public string Name { get; private set; } = string.Empty;
public string Surname { get; set; } = string.Empty; public string Surname { get; private set; } = string.Empty;
public string Login { get; set; } = string.Empty; public string Login { get; private set; } = string.Empty;
public string Password { get; set; } = string.Empty; public string Password { get; private set; } = string.Empty;
public string Phone { get; set; } = string.Empty; public string Phone { get; private set; } = string.Empty;
public static Employee? Create(EmployeeBindingModel model) public static Employee? Create(EmployeeBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -5,12 +5,12 @@ using System.Reflection;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Procedure internal class Procedure
{ {
public int Id { get; set; } public int Id { get; private set; }
public string Name { get; set; } = string.Empty; public string Name { get; private set; } = string.Empty;
public double Price { get; set; } public double Price { get; private set; }
public string FIO_Master { get; set; } = string.Empty; public string FIO_Master { get; private set; } = string.Empty;
public static Procedure? Create(ProcedureBindingModel model) public static Procedure? Create(ProcedureBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -4,11 +4,11 @@ using BeautySalonContracts.ViewModels;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Purchase internal class Purchase
{ {
public int Id { get; set; } public int Id { get; private set; }
public DateTime Date { get; set; } public DateTime Date { get; private set; }
public double Sum { get; set; } public double Sum { get; private set; }
public static Purchase? Create(PurchaseBindingModel model) public static Purchase? Create(PurchaseBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -4,11 +4,11 @@ using BeautySalonContracts.ViewModels;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Receipt internal class Receipt
{ {
public int Id { get; set; } public int Id { get; private set; }
public DateTime Date { get; set; } public DateTime Date { get; private set; }
public double Sum { get; set; } public double Sum { get; private set; }
public static Receipt? Create(ReceiptBindingModel model) public static Receipt? Create(ReceiptBindingModel model)
{ {
if (model == null) if (model == null)

View File

@ -4,11 +4,11 @@ using BeautySalonContracts.ViewModels;
namespace BeautySalonDatabaseImplement.Models namespace BeautySalonDatabaseImplement.Models
{ {
public class Visit internal class Visit
{ {
public int Id { get; set; } public int Id { get; private set; }
public DateTime Date { get; set; } public DateTime Date { get; private set; }
public double Sum { get; set; } public double Sum { get; private set; }
public static Visit? Create(VisitBindingModel model) public static Visit? Create(VisitBindingModel model)
{ {