Сохранение перед убийством
This commit is contained in:
parent
db49f38477
commit
4db0c02206
@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonContracts", "Be
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonBusinessLogic", "BeautySaloonBusinessLogic\BeautySaloonBusinessLogic.csproj", "{E43A1394-BC9A-430B-B984-BCCD828FFF45}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonBusinessLogic", "BeautySaloonBusinessLogic\BeautySaloonBusinessLogic.csproj", "{E43A1394-BC9A-430B-B984-BCCD828FFF45}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySaloonDatabaseImplement", "BeautySaloonDatabaseImplement\BeautySaloonDatabaseImplement.csproj", "{BB7AD640-FF4A-415B-A09B-BB802D64CE27}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -33,6 +35,10 @@ Global
|
|||||||
{E43A1394-BC9A-430B-B984-BCCD828FFF45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E43A1394-BC9A-430B-B984-BCCD828FFF45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E43A1394-BC9A-430B-B984-BCCD828FFF45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E43A1394-BC9A-430B-B984-BCCD828FFF45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E43A1394-BC9A-430B-B984-BCCD828FFF45}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E43A1394-BC9A-430B-B984-BCCD828FFF45}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BB7AD640-FF4A-415B-A09B-BB802D64CE27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BB7AD640-FF4A-415B-A09B-BB802D64CE27}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BB7AD640-FF4A-415B-A09B-BB802D64CE27}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BB7AD640-FF4A-415B-A09B-BB802D64CE27}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public DateTime? Date { get; set; }
|
public DateTime? Date { get; set; }
|
||||||
public int? Client_Id { get; set; }
|
public int? ClientId { get; set; }
|
||||||
public int? Employee_Id { get; set; }
|
public int? EmployeeId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
using BeautySaloonDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement
|
||||||
|
{
|
||||||
|
public class BeautySaloonDatabase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D8KMQQU\SQLEXPRESS;Initial Catalog=SushiBarDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DbSet<Employee> Employees { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<Position> Positions { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<Service> Services { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
|
||||||
|
public virtual DbSet<ServiceOrder> OrderServices { set; get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Implements\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BeautySaloonContracts\BeautySaloonContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
52
BeautySaloon/BeautySaloonDatabaseImplement/Models/Client.cs
Normal file
52
BeautySaloon/BeautySaloonDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using BeautySaloonContracts.BindingModels;
|
||||||
|
using BeautySaloonContracts.ViewModels;
|
||||||
|
using BeautySaloonDataModels;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Surname { get; set; } = string.Empty;
|
||||||
|
public string Patronymic { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
public static Client Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
return new Client()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Surname = model.Surname,
|
||||||
|
Patronymic = model.Patronymic,
|
||||||
|
Phone = model.Phone
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
Name = model.Name;
|
||||||
|
Surname = model.Surname;
|
||||||
|
Patronymic = model.Patronymic;
|
||||||
|
Phone = model.Phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Surname = Surname,
|
||||||
|
Patronymic = Patronymic,
|
||||||
|
Phone = Phone
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
using BeautySaloonContracts.BindingModels;
|
||||||
|
using BeautySaloonContracts.ViewModels;
|
||||||
|
using BeautySaloonDataModels;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Employee : IEmployeeModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Surname { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Patronymic { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Phone { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int PositionId { get; set; }
|
||||||
|
public Position Position { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("EmployeeId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
[ForeignKey("EmployeeId")]
|
||||||
|
public virtual List<ServiceOrder> OrderServices { get; set; } = new();
|
||||||
|
|
||||||
|
public static Employee? Create(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Employee()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Surname = model.Surname,
|
||||||
|
Patronymic = model.Patronymic,
|
||||||
|
Phone = model.Phone,
|
||||||
|
PositionId = model.PositionId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(EmployeeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
Surname = model.Surname;
|
||||||
|
Patronymic = model.Patronymic;
|
||||||
|
Phone = model.Phone;
|
||||||
|
PositionId = model.PositionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmployeeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Surname = Surname,
|
||||||
|
Patronymic = Patronymic,
|
||||||
|
Phone = Phone,
|
||||||
|
PositionId = PositionId,
|
||||||
|
PositionName = Position.Name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
38
BeautySaloon/BeautySaloonDatabaseImplement/Models/Order.cs
Normal file
38
BeautySaloon/BeautySaloonDatabaseImplement/Models/Order.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using BeautySaloonDataModels;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Order : IOrderModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
[Required]
|
||||||
|
public double Sum { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
|
|
||||||
|
private Dictionary<int, (DateTime, IServiceModel, IEmployeeModel)>? _orderServices = null;
|
||||||
|
[ForeignKey("OrderId")]
|
||||||
|
public virtual List<ServiceOrder> Services { get; set; } = new();
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, (DateTime, IServiceModel, IEmployeeModel)> OrderServices
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
/*if (_orderServices == null)
|
||||||
|
{
|
||||||
|
_orderServices = Services
|
||||||
|
.ToDictionary(recPC => recPC.ServiceId,
|
||||||
|
recPC => (recPC.Service as IServiceModel, recPC.Count));
|
||||||
|
}*/
|
||||||
|
return _orderServices;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
using BeautySaloonContracts.BindingModels;
|
||||||
|
using BeautySaloonContracts.ViewModels;
|
||||||
|
using BeautySaloonDataModels;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Position : IPositionModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[ForeignKey("PositionId")]
|
||||||
|
public virtual List<Employee> Employees { get; set; } = new();
|
||||||
|
|
||||||
|
public static Position Create(PositionBindingModel model)
|
||||||
|
{
|
||||||
|
return new Position()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(PositionBindingModel model)
|
||||||
|
{
|
||||||
|
Name = model.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PositionViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
41
BeautySaloon/BeautySaloonDatabaseImplement/Models/Service.cs
Normal file
41
BeautySaloon/BeautySaloonDatabaseImplement/Models/Service.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using BeautySaloonContracts.BindingModels;
|
||||||
|
using BeautySaloonDataModels;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using BeautySaloonContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Service : IServiceModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double Price { get; set; }
|
||||||
|
[ForeignKey("ServiceId")]
|
||||||
|
public virtual List<ServiceOrder> OrderServices { get; set; } = new();
|
||||||
|
|
||||||
|
public static Service Create(ServiceBindingModel model)
|
||||||
|
{
|
||||||
|
return new Service()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Price = model.Price
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ServiceBindingModel model)
|
||||||
|
{
|
||||||
|
Name = model.Name;
|
||||||
|
Price = model.Price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Price = Price
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace BeautySaloonDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ServiceOrder
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public int ServiceId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int OrderId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int EmployeeId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
public virtual Service Service { get; set; } = new();
|
||||||
|
|
||||||
|
public virtual Order Order { get; set; } = new();
|
||||||
|
|
||||||
|
public virtual Employee Employee { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user