Compare commits
No commits in common. "9577664444a49604721a33b78d9d82d0c5fc9e5e" and "32ddb232e5a18dbf76d1dc43b4c9bcd9cbc30b27" have entirely different histories.
9577664444
...
32ddb232e5
@ -8,17 +8,4 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonBusinessLogic\BeautySalonBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonDatabaseImplement\BeautySalonDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\BeautySalonDataModels\BeautySalonDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonContracts", "..\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonBusinessLogic", "..\BeautySalonBusinessLogic\BeautySalonBusinessLogic.csproj", "{EC867077-D21F-4D12-9BD5-16244A3D119C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeautySalonDatabaseImplement", "..\BeautySalonDatabaseImplement\BeautySalonDatabaseImplement.csproj", "{BD110484-1896-428D-962D-A0EAE2AAD41E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -35,10 +33,6 @@ Global
|
||||
{EC867077-D21F-4D12-9BD5-16244A3D119C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EC867077-D21F-4D12-9BD5-16244A3D119C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EC867077-D21F-4D12-9BD5-16244A3D119C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BD110484-1896-428D-962D-A0EAE2AAD41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BD110484-1896-428D-962D-A0EAE2AAD41E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD110484-1896-428D-962D-A0EAE2AAD41E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD110484-1896-428D-962D-A0EAE2AAD41E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,22 +0,0 @@
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BeautySalonDatabaseImplement
|
||||
{
|
||||
public class BeautySalonDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IHH1ICP\SQLEXPRESS;Initial Catalog=BeautySalonDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Master> Masters { set; get; }
|
||||
public virtual DbSet<Service> Services { set; get; }
|
||||
public virtual DbSet<MasterService> MasterServices { set; get; }
|
||||
public virtual DbSet<Visit> Visits { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BeautySalonDataModels\BeautySalonDataModels.csproj" />
|
||||
<ProjectReference Include="..\BeauySalonContracts\BeautySalonContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,82 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Clients.FirstOrDefault(x => (!string.IsNullOrEmpty(model.PhoneNumber) && x.PhoneNumber == model.PhoneNumber) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PhoneNumber))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Clients
|
||||
.Where(x => x.PhoneNumber.Equals(model.PhoneNumber))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Clients
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
context.Clients.Add(newClient);
|
||||
context.SaveChanges();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (client == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
client.Update(model);
|
||||
context.SaveChanges();
|
||||
return client.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class MasterStorage : IMasterStorage
|
||||
{
|
||||
public List<MasterViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Masters
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<MasterViewModel> GetFilteredList(MasterSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MasterFIO))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Masters
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.Where(x => x.MasterFIO.Contains(model.MasterFIO))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public MasterViewModel? GetElement(MasterSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MasterFIO) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Masters
|
||||
.Include(x => x.Services)
|
||||
.ThenInclude(x => x.Service)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.MasterFIO) &&
|
||||
x.MasterFIO == model.MasterFIO) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public MasterViewModel? Insert(MasterBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var newMaster = Master.Create(context, model);
|
||||
if (newMaster == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Masters.Add(newMaster);
|
||||
context.SaveChanges();
|
||||
return newMaster.GetViewModel;
|
||||
}
|
||||
public MasterViewModel? Update(MasterBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var engine = context.Masters.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (engine == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
engine.Update(model);
|
||||
context.SaveChanges();
|
||||
engine.UpdateServices(context, model);
|
||||
transaction.Commit();
|
||||
return engine.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public MasterViewModel? Delete(MasterBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Masters
|
||||
.Include(x => x.Services)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Masters.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using System.ServiceModel;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class ServiceStorage : IServiceStorage
|
||||
{
|
||||
public List<ServiceViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Services
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<ServiceViewModel> GetFilteredList(ServiceSearchModel
|
||||
model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ServiceName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Services
|
||||
.Where(x => x.ServiceName.Contains(model.ServiceName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public ServiceViewModel? GetElement(ServiceSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ServiceName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Services
|
||||
.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ServiceName) && x.ServiceName ==
|
||||
model.ServiceName) || (model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public ServiceViewModel? Insert(ServiceBindingModel model)
|
||||
{
|
||||
var newService = Service.Create(model);
|
||||
if (newService == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
context.Services.Add(newService);
|
||||
context.SaveChanges();
|
||||
return newService.GetViewModel;
|
||||
}
|
||||
public ServiceViewModel? Update(ServiceBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var component = context.Services.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
public ServiceViewModel? Delete(ServiceBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Services.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Services.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.SearchModels;
|
||||
using BeautySalonContracts.StoragesContracts;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Implements
|
||||
{
|
||||
public class VisitStorage : IVisitStorage
|
||||
{
|
||||
public VisitViewModel? Delete(VisitBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var element = context.Visits.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Visits.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public VisitViewModel? GetElement(VisitSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Visits.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<VisitViewModel> GetFilteredList(VisitSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Visits.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<VisitViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
return context.Visits.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public VisitViewModel? Insert(VisitBindingModel model)
|
||||
{
|
||||
var newVisit = Visit.Create(model);
|
||||
if (newVisit == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BeautySalonDatabase();
|
||||
context.Visits.Add(newVisit);
|
||||
context.SaveChanges();
|
||||
return newVisit.GetViewModel;
|
||||
}
|
||||
|
||||
public VisitViewModel? Update(VisitBindingModel model)
|
||||
{
|
||||
using var context = new BeautySalonDatabase();
|
||||
var order = context.Visits.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,225 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
[Migration("20230513120245_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Specialization")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Masters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("MasterServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateOfVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("MasterServices")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Navigation("Services");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("MasterServices");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Masters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MasterFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Specialization = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Masters", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Services",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Services", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "MasterServices",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MasterId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_MasterServices", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_MasterServices_Masters_MasterId",
|
||||
column: x => x.MasterId,
|
||||
principalTable: "Masters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_MasterServices_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Visits",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DateOfVisit = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
MasterId = table.Column<int>(type: "int", nullable: false),
|
||||
ServiceId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
MasterFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Visits", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Masters_MasterId",
|
||||
column: x => x.MasterId,
|
||||
principalTable: "Masters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Visits_Services_ServiceId",
|
||||
column: x => x.ServiceId,
|
||||
principalTable: "Services",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MasterServices_MasterId",
|
||||
table: "MasterServices",
|
||||
column: "MasterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MasterServices_ServiceId",
|
||||
table: "MasterServices",
|
||||
column: "ServiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ClientId",
|
||||
table: "Visits",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_MasterId",
|
||||
table: "Visits",
|
||||
column: "MasterId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Visits_ServiceId",
|
||||
table: "Visits",
|
||||
column: "ServiceId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "MasterServices");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Visits");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Masters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Services");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BeautySalonDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BeautySalonDatabase))]
|
||||
partial class BeautySalonDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.5")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Specialization")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Masters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("MasterServices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Services");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateOfVisit")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("MasterFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MasterId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ServiceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ServiceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MasterId");
|
||||
|
||||
b.HasIndex("ServiceId");
|
||||
|
||||
b.ToTable("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MasterService", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Services")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany("MasterServices")
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Visit", b =>
|
||||
{
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Master", "Master")
|
||||
.WithMany("Visits")
|
||||
.HasForeignKey("MasterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Master");
|
||||
|
||||
b.Navigation("Service");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Master", b =>
|
||||
{
|
||||
b.Navigation("Services");
|
||||
|
||||
b.Navigation("Visits");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
|
||||
{
|
||||
b.Navigation("MasterServices");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ClientFIO { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
public static Client Create(ClientViewModel model)
|
||||
{
|
||||
return new Client
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientFIO = model.ClientFIO,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ClientFIO = model.ClientFIO;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientFIO = ClientFIO,
|
||||
PhoneNumber = PhoneNumber
|
||||
};
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Master : IMasterModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Specialization { get; set; } = string.Empty;
|
||||
private Dictionary<int, (IServiceModel, int)>? _masterServices = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IServiceModel, int)> MasterServices
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_masterServices == null)
|
||||
{
|
||||
_masterServices = Services
|
||||
.ToDictionary(recPC => recPC.MasterId, recPC =>
|
||||
(recPC.Service as IServiceModel, recPC.Count));
|
||||
}
|
||||
return _masterServices;
|
||||
}
|
||||
}
|
||||
[ForeignKey("MasterId")]
|
||||
public virtual List<MasterService> Services { get; set; } = new();
|
||||
[ForeignKey("MasterId")]
|
||||
public virtual List<Visit> Visits { get; set; } = new();
|
||||
public static Master Create(BeautySalonDatabase context, MasterBindingModel model)
|
||||
{
|
||||
return new Master
|
||||
{
|
||||
Id = model.Id,
|
||||
MasterFIO = model.MasterFIO,
|
||||
Specialization = model.Specialization,
|
||||
Services = model.MasterServices.Select(x => new MasterService
|
||||
{
|
||||
Service = context.Services.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(MasterBindingModel model)
|
||||
{
|
||||
MasterFIO = model.MasterFIO;
|
||||
Specialization = model.Specialization;
|
||||
}
|
||||
public MasterViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
MasterFIO = MasterFIO,
|
||||
Specialization = Specialization,
|
||||
MasterServices = MasterServices
|
||||
};
|
||||
public void UpdateServices(BeautySalonDatabase context, MasterBindingModel model)
|
||||
{
|
||||
var masterServices = context.MasterServices.Where(rec => rec.MasterId == model.Id).ToList();
|
||||
if (masterServices != null && masterServices.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.MasterServices.RemoveRange(masterServices.Where(rec
|
||||
=> !model.MasterServices.ContainsKey(rec.ServiceId)));
|
||||
context.SaveChanges();
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateService in masterServices)
|
||||
{
|
||||
updateService.Count =
|
||||
model.MasterServices[updateService.ServiceId].Item2;
|
||||
model.MasterServices.Remove(updateService.ServiceId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
var master = context.Masters.First(x => x.Id == Id);
|
||||
foreach (var pc in model.MasterServices)
|
||||
{
|
||||
context.MasterServices.Add(new MasterService
|
||||
{
|
||||
Master = master,
|
||||
Service = context.Services.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_masterServices = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class MasterService
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int MasterId { get; set; }
|
||||
[Required]
|
||||
public int ServiceId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Service Service { get; set; } = new();
|
||||
public virtual Master Master { get; set; } = new();
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Service : IServiceModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ServiceName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[ForeignKey("ServiceId")]
|
||||
public virtual List<MasterService> MasterServices { get; set; } = new();
|
||||
public static Service? Create(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Service()
|
||||
{
|
||||
Id = model.Id,
|
||||
ServiceName = model.ServiceName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public static Service Create(ServiceViewModel model)
|
||||
{
|
||||
return new Service
|
||||
{
|
||||
Id = model.Id,
|
||||
ServiceName = model.ServiceName,
|
||||
Cost = model.Cost
|
||||
};
|
||||
}
|
||||
public void Update(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ServiceName = model.ServiceName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
public ServiceViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ServiceName = ServiceName,
|
||||
Cost = Cost
|
||||
};
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
using BeautySalonContracts.BindingModels;
|
||||
using BeautySalonContracts.ViewModels;
|
||||
using BeautySalonDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BeautySalonDatabaseImplement.Models
|
||||
{
|
||||
public class Visit : IVisitModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public DateTime DateOfVisit { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
public int MasterId { get; private set; }
|
||||
public int ServiceId { get; private set; }
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
public virtual Client Client { get; set; }
|
||||
public virtual Master Master { get; set; }
|
||||
public virtual Service Service { get; set; }
|
||||
|
||||
public static Visit? Create(VisitBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Visit()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientId = model.ClientId,
|
||||
ClientFIO = model.ClientFIO,
|
||||
MasterId = model.MasterId,
|
||||
MasterFIO = model.MasterFIO,
|
||||
ServiceId = model.ServiceId,
|
||||
ServiceName = model.ServiceName,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
DateOfVisit = model.DateOfVisit
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(VisitBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientId = model.ClientId;
|
||||
ClientFIO = model.ClientFIO;
|
||||
MasterId = model.MasterId;
|
||||
MasterFIO = model.MasterFIO;
|
||||
ServiceId = model.ServiceId;
|
||||
ServiceName = model.ServiceName;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
DateOfVisit = model.DateOfVisit;
|
||||
}
|
||||
|
||||
public VisitViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = ClientFIO,
|
||||
MasterId = MasterId,
|
||||
MasterFIO = MasterFIO,
|
||||
ServiceId = ServiceId,
|
||||
ServiceName = ServiceName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateOfVisit = DateOfVisit
|
||||
};
|
||||
}
|
||||
}
|
@ -7,6 +7,5 @@ namespace BeautySalonContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
public string Specialization { get; set; } = string.Empty;
|
||||
public Dictionary<int, (IServiceModel, int)> MasterServices { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,6 @@ namespace BeautySalonContracts.BindingModels
|
||||
public int ClientId { get; set; }
|
||||
public int MasterId { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
public double Sum { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
@ -9,14 +9,8 @@ namespace BeautySalonContracts.ViewModels
|
||||
[DisplayName("Дата посещения")]
|
||||
public DateTime DateOfVisit { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public int MasterId { get; set; }
|
||||
[DisplayName("Мастер")]
|
||||
public string MasterFIO { get; set; } = string.Empty;
|
||||
public int ServiceId { get; set; }
|
||||
[DisplayName("Услуга")]
|
||||
public string ServiceName { get; set; } = string.Empty;
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Количество")]
|
||||
|
Loading…
Reference in New Issue
Block a user