add databese implement
This commit is contained in:
parent
9b2215c7ae
commit
074b729966
@ -0,0 +1,33 @@
|
|||||||
|
using FurnitureAssemblyStorekeeperDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement
|
||||||
|
{
|
||||||
|
public class FurnitureAssemblyDatabase : DbContext
|
||||||
|
{
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
if (optionsBuilder.IsConfigured == false)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseNpgsql("Host=zyzf.space;Port=5434;Database=kursach;Username=postgres;Password=kursach");
|
||||||
|
}
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
}
|
||||||
|
public virtual DbSet<Set> Sets { get; set; }
|
||||||
|
public virtual DbSet<SetFurnitureModule> SetFurnitureModules { get; set; }
|
||||||
|
public virtual DbSet<FurnitureModule> FurnitureModules { get; set; }
|
||||||
|
public virtual DbSet<FurnitureModuleFurniture> FurnitureModuleFurnitures { get; set; }
|
||||||
|
public virtual DbSet<Furniture> Furnitures { get; set; }
|
||||||
|
public virtual DbSet<FurnitureMaterial> FurnitureMaterials { get; set; }
|
||||||
|
public virtual DbSet<Material> Materials { get; set; }
|
||||||
|
public virtual DbSet<Role> Roles { get; set; }
|
||||||
|
public virtual DbSet<Scope> Scopes { get; set; }
|
||||||
|
public virtual DbSet<User> Users { get; set; }
|
||||||
|
public virtual DbSet<Order> Orders { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<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.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FurnitureAssembly_Storekeeper_Contracts\FurnitureAssembly_Storekeeper_Contracts.csproj" />
|
||||||
|
<ProjectReference Include="..\FurnitureAssembly_Storekeeper_Models\FurnitureAssembly_Storekeeper_DataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,117 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.SearchModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.StoragesContracts;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssemblyStorekeeperDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class FurnitureStorage : IFurnitureStorage
|
||||||
|
{
|
||||||
|
public List<FurnitureViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Furnitures
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.ThenInclude(x => x.Material).ToList()
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
if (!string.IsNullOrEmpty(model.FurnitureName))
|
||||||
|
{
|
||||||
|
return context.Furnitures
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.ThenInclude(x => x.Material)
|
||||||
|
.Where(x => x.Name.Contains(model.FurnitureName)).ToList()
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
else if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Furnitures
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.ThenInclude(x => x.Material)
|
||||||
|
.Where(x => x.UserId == model.UserId)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.FurnitureName) &&
|
||||||
|
!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Furnitures.Include(x => x.User)
|
||||||
|
.Include(x => x.Materials).ThenInclude(x => x.Material)
|
||||||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) && x.Name == model.FurnitureName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var newFurniture = Furniture.Create(context, model);
|
||||||
|
if (newFurniture == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Furnitures.Add(newFurniture);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newFurniture.GetViewModel;
|
||||||
|
}
|
||||||
|
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var furniture = context.Furnitures
|
||||||
|
.Include(x => x.User)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (furniture == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
furniture.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
furniture.UpdateMaterials(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return furniture.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var element = context.Furnitures
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Furnitures.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.SearchModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.StoragesContracts;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssemblyStorekeeperDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class MaterialStorage : IMaterialStorage
|
||||||
|
{
|
||||||
|
public List<MaterialViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Materials
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Scope)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public List<MaterialViewModel> GetFilteredList(MaterialSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
if (!string.IsNullOrEmpty(model.MaterialName))
|
||||||
|
{
|
||||||
|
return context.Materials
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Scope)
|
||||||
|
.Where(x => x.Name.Contains(model.MaterialName))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public MaterialViewModel? GetElement(MaterialSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.MaterialName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Materials
|
||||||
|
.Include(x => x.User)
|
||||||
|
.Include(x => x.Scope)
|
||||||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.MaterialName) && x.Name == model.MaterialName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public MaterialViewModel? Insert(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
var newMaterial = Material.Create(model);
|
||||||
|
if (newMaterial == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
context.Materials.Add(newMaterial);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newMaterial.GetViewModel;
|
||||||
|
}
|
||||||
|
public MaterialViewModel? Update(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var material = context.Materials
|
||||||
|
.Include(x => x.User)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (material == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
material.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return material.GetViewModel;
|
||||||
|
}
|
||||||
|
public MaterialViewModel? Delete(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var element = context.Materials
|
||||||
|
.Include(x => x.User)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Materials.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.SearchModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.StoragesContracts;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssemblyStorekeeperDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ScopeStorage : IScopeStorage
|
||||||
|
{
|
||||||
|
public List<ScopeViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Scopes
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public List<ScopeViewModel> GetFilteredList(ScopeSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.ScopeName))
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Scopes
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.Where(x => x.Name.Contains(model.ScopeName))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
public ScopeViewModel? GetElement(ScopeSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Scopes
|
||||||
|
.FirstOrDefault(x => (x.Id == model.Id))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(model.ScopeName))
|
||||||
|
{
|
||||||
|
return context.Scopes
|
||||||
|
.FirstOrDefault(x => (x.Name == model.ScopeName))
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
public ScopeViewModel? Insert(ScopeBindingModel model)
|
||||||
|
{
|
||||||
|
var newScope = Scope.Create(model);
|
||||||
|
if (newScope == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
context.Scopes.Add(newScope);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newScope.GetViewModel;
|
||||||
|
}
|
||||||
|
public ScopeViewModel? Update(ScopeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var scope = context.Scopes
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (scope == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
scope.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return scope.GetViewModel;
|
||||||
|
}
|
||||||
|
public ScopeViewModel? Delete(ScopeBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var element = context.Scopes
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Scopes.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.SearchModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.StoragesContracts;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssemblyStorekeeperDatabaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class UserStorage : IUserStorage
|
||||||
|
{
|
||||||
|
public UserViewModel? Delete(UserBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var element = context
|
||||||
|
.Users.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
var deletedElement = context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
context.Users.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return deletedElement;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public UserViewModel? GetElement(UserSearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public List<UserViewModel> GetFilteredList(UserSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.RoleId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.Where(x => x.RoleId == model.RoleId)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<UserViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
return context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public UserViewModel? Insert(UserBindingModel model)
|
||||||
|
{
|
||||||
|
var newUser = User.Create(model);
|
||||||
|
if (newUser == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
context.Users.Add(newUser);
|
||||||
|
context.SaveChanges();
|
||||||
|
return context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.FirstOrDefault(x => x.Id == newUser.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
public UserViewModel? Update(UserBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new FurnitureAssemblyDatabase();
|
||||||
|
var user = context.Users.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
user.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return context.Users
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Include(x => x.Furnitures)
|
||||||
|
.Include(x => x.Materials)
|
||||||
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Furniture : IFurniture
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double Cost { get; set; }
|
||||||
|
[Required]
|
||||||
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public virtual IUser User{ get; set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (IMaterial, int)>? _furnitureMaterials = null;
|
||||||
|
[NotMapped]
|
||||||
|
public Dictionary<int, (IMaterial, int)> FurnitureMaterials
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_furnitureMaterials == null)
|
||||||
|
{
|
||||||
|
_furnitureMaterials = Materials
|
||||||
|
.ToDictionary(recPC => recPC.MaterialId, recPC =>
|
||||||
|
(recPC.Material as IMaterial, recPC.Count));
|
||||||
|
}
|
||||||
|
return _furnitureMaterials;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[ForeignKey("FurnitureId")]
|
||||||
|
public virtual List<FurnitureMaterial> Materials { get; set; } = new();
|
||||||
|
public static Furniture Create(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||||
|
{
|
||||||
|
return new Furniture()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Cost = model.Cost,
|
||||||
|
UserId = model.User.Id,
|
||||||
|
DateCreate = model.DateCreate,
|
||||||
|
Materials = model.FurnitureMaterials.Select(x => new FurnitureMaterial
|
||||||
|
{
|
||||||
|
Material = context.Materials.First(y => y.Id == x.Key),
|
||||||
|
Count = x.Value.Item2
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(FurnitureBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
Cost = model.Cost;
|
||||||
|
}
|
||||||
|
public FurnitureViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Cost = Cost,
|
||||||
|
User = User,
|
||||||
|
DateCreate = DateCreate,
|
||||||
|
FurnitureMaterials = FurnitureMaterials
|
||||||
|
};
|
||||||
|
|
||||||
|
Dictionary<int, (IMaterial, int)> IFurniture.FurnitureMaterials => throw new NotImplementedException();
|
||||||
|
|
||||||
|
IUser IFurniture.User => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public void UpdateMaterials(FurnitureAssemblyDatabase context, FurnitureBindingModel model)
|
||||||
|
{
|
||||||
|
var furnitureMaterials = context.FurnitureMaterials.Where(rec =>
|
||||||
|
rec.FurnitureId == model.Id).ToList();
|
||||||
|
if (furnitureMaterials != null && furnitureMaterials.Count > 0)
|
||||||
|
{ // удалили те, которых нет в модели
|
||||||
|
context.FurnitureMaterials.RemoveRange(furnitureMaterials.Where(rec
|
||||||
|
=> !model.FurnitureMaterials.ContainsKey(rec.MaterialId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
// обновили количество у существующих записей
|
||||||
|
foreach (var updateMaterial in furnitureMaterials)
|
||||||
|
{
|
||||||
|
updateMaterial.Count = model.FurnitureMaterials[updateMaterial.MaterialId].Item2;
|
||||||
|
model.FurnitureMaterials.Remove(updateMaterial.MaterialId);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
var furniture = context.Furnitures.First(x => x.Id == Id);
|
||||||
|
foreach (var pc in model.FurnitureMaterials)
|
||||||
|
{
|
||||||
|
context.FurnitureMaterials.Add(new FurnitureMaterial
|
||||||
|
{
|
||||||
|
Furniture = furniture,
|
||||||
|
Material = context.Materials.First(x => x.Id == pc.Key),
|
||||||
|
Count = pc.Value.Item2
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_furnitureMaterials = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class FurnitureMaterial
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int FurnitureId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int MaterialId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
public virtual Furniture Furniture { get; set; } = new();
|
||||||
|
public virtual Material Material { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_DataModels.Models;
|
||||||
|
using FurnitureAssemblyStorekeeperDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Material : IMaterial
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public double Cost { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int ScopeId { get; set; }
|
||||||
|
public virtual IScope Scope { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
[ForeignKey("MaterialId")]
|
||||||
|
public virtual List<FurnitureMaterial> FurnitureMaterials { get; set; } = new();
|
||||||
|
public static Material? Create(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Material()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Cost = model.Cost,
|
||||||
|
ScopeId = model.Scope.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(MaterialBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
Cost = model.Cost;
|
||||||
|
ScopeId = model.Scope.Id;
|
||||||
|
}
|
||||||
|
public MaterialViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name,
|
||||||
|
Cost = Cost,
|
||||||
|
Scope = Scope
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_DataModels.Models;
|
||||||
|
using FurnitureAssembly_WorkerDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Role : IRole
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[ForeignKey("RoleId")]
|
||||||
|
public virtual List<User> Users { get; set; } = new();
|
||||||
|
public static Role? Create(RoleBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Role()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(RoleBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
}
|
||||||
|
public RoleViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Scope : IScope
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[ForeignKey("ScopeId")]
|
||||||
|
public virtual List<Material> Materials { get; set; } = new();
|
||||||
|
public static Scope? Create(ScopeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Scope()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ScopeBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Name = model.Name;
|
||||||
|
}
|
||||||
|
public ScopeViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Name = Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
using FurnitureAssembly_Storekeeper_Contracts.BindingModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_Contracts.ViewModels;
|
||||||
|
using FurnitureAssembly_Storekeeper_DataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class User : IUser
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Login { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string UserName { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public int RoleId { get; set; }
|
||||||
|
public virtual IRole Role { get; set; }
|
||||||
|
[ForeignKey("UserId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
[ForeignKey("FurnitureId")]
|
||||||
|
public virtual List<Furniture> Furnitures { get; set; } = new();
|
||||||
|
[ForeignKey("MaterialId")]
|
||||||
|
public virtual List<Material> Materials { get; set; } = new();
|
||||||
|
public static User? Create(UserBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new User()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Login = model.Login,
|
||||||
|
Password = model.Password,
|
||||||
|
UserName = model.UserName,
|
||||||
|
RoleId = model.Role.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(UserBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Login = model.Login;
|
||||||
|
Password = model.Password;
|
||||||
|
UserName = model.UserName;
|
||||||
|
RoleId = model.Role.Id;
|
||||||
|
}
|
||||||
|
public UserViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Password = Password,
|
||||||
|
Login = Login,
|
||||||
|
UserName = UserName,
|
||||||
|
Role = Role
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -7,9 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly_Storekeep
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly_Storekeeper_DataModels", "FurnitureAssembly_Storekeeper_Models\FurnitureAssembly_Storekeeper_DataModels.csproj", "{30209964-F5C9-441D-A83D-7462ECE07B06}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly_Storekeeper_DataModels", "FurnitureAssembly_Storekeeper_Models\FurnitureAssembly_Storekeeper_DataModels.csproj", "{30209964-F5C9-441D-A83D-7462ECE07B06}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssembly_Storekeeper_Contracts", "FurnitureAssembly_Storekeeper_Contracts\FurnitureAssembly_Storekeeper_Contracts.csproj", "{487F90DA-C4AC-4407-A382-953DA3689C2A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly_Storekeeper_Contracts", "FurnitureAssembly_Storekeeper_Contracts\FurnitureAssembly_Storekeeper_Contracts.csproj", "{487F90DA-C4AC-4407-A382-953DA3689C2A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssembly_Storekeeper_BusinessLogic", "FurnitureAssembly_Storekeeper_BusinessLogic\FurnitureAssembly_Storekeeper_BusinessLogic.csproj", "{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssembly_Storekeeper_BusinessLogic", "FurnitureAssembly_Storekeeper_BusinessLogic\FurnitureAssembly_Storekeeper_BusinessLogic.csproj", "{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyStorekeeperDatabaseImplement", "FurnitureAssemblyStorekeeperDatabaseImplement\FurnitureAssemblyStorekeeperDatabaseImplement.csproj", "{3FE1A0A6-FA67-4F4C-9167-97164498D927}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -33,6 +35,10 @@ Global
|
|||||||
{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EC0BAC5C-D13B-4BB1-9E88-68FC69995BC6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3FE1A0A6-FA67-4F4C-9167-97164498D927}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3FE1A0A6-FA67-4F4C-9167-97164498D927}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3FE1A0A6-FA67-4F4C-9167-97164498D927}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3FE1A0A6-FA67-4F4C-9167-97164498D927}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -92,18 +92,18 @@ namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет названия продукта",nameof(model.FurnitureName));
|
throw new ArgumentNullException("Нет названия продукта",nameof(model.Name));
|
||||||
}
|
}
|
||||||
if (model.FurnitureCost <= 0)
|
if (model.Cost <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.FurnitureCost));
|
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Furniture. FurnitureName:{FurnitureName}. Cost:{Cost}. Id: {Id}", model.FurnitureName, model.FurnitureCost, model.Id);
|
_logger.LogInformation("Furniture. FurnitureName:{FurnitureName}. Cost:{Cost}. Id: {Id}", model.Name, model.Cost, model.Id);
|
||||||
var element = _FurnitureStorage.GetElement(new FurnitureSearchModel
|
var element = _FurnitureStorage.GetElement(new FurnitureSearchModel
|
||||||
{
|
{
|
||||||
FurnitureName = model.FurnitureName
|
FurnitureName = model.Name
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
|
@ -90,19 +90,19 @@ namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.MaterialName))
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет названия компонента",
|
throw new ArgumentNullException("Нет названия компонента",
|
||||||
nameof(model.MaterialName));
|
nameof(model.Name));
|
||||||
}
|
}
|
||||||
if (model.Cost <= 0)
|
if (model.Cost <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Material. MaterialName:{MaterialName}. Cost:{ Cost}. Id: {Id}", model.MaterialName, model.Cost, model.Id);
|
_logger.LogInformation("Material. MaterialName:{MaterialName}. Cost:{ Cost}. Id: {Id}", model.Name, model.Cost, model.Id);
|
||||||
var element = _MaterialStorage.GetElement(new MaterialSearchModel
|
var element = _MaterialStorage.GetElement(new MaterialSearchModel
|
||||||
{
|
{
|
||||||
MaterialName = model.MaterialName
|
MaterialName = model.Name
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
|
@ -90,16 +90,16 @@ namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.RoleName))
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет названия роли",
|
throw new ArgumentNullException("Нет названия роли",
|
||||||
nameof(model.RoleName));
|
nameof(model.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Role. RoleName:{RoleName}. Id: {Id}", model.RoleName, model.Id);
|
_logger.LogInformation("Role. RoleName:{RoleName}. Id: {Id}", model.Name, model.Id);
|
||||||
var element = _RoleStorage.GetElement(new RoleSearchModel
|
var element = _RoleStorage.GetElement(new RoleSearchModel
|
||||||
{
|
{
|
||||||
RoleName = model.RoleName
|
RoleName = model.Name
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
|
@ -90,15 +90,15 @@ namespace FurnitureAssembly_Storekeeper_BusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.ScopeName))
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет названия области использования",
|
throw new ArgumentNullException("Нет названия области использования",
|
||||||
nameof(model.ScopeName));
|
nameof(model.Name));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Scope. ScopeName:{ScopeName}. Id: {Id}", model.ScopeName,model.Id);
|
_logger.LogInformation("Scope. ScopeName:{ScopeName}. Id: {Id}", model.Name,model.Id);
|
||||||
var element = _ScopeStorage.GetElement(new ScopeSearchModel
|
var element = _ScopeStorage.GetElement(new ScopeSearchModel
|
||||||
{
|
{
|
||||||
ScopeName = model.ScopeName
|
ScopeName = model.Name
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,9 @@ namespace FurnitureAssembly_Storekeeper_Contracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class FurnitureBindingModel : IFurniture
|
public class FurnitureBindingModel : IFurniture
|
||||||
{
|
{
|
||||||
public string FurnitureName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public double FurnitureCost {get; set; }
|
public double Cost {get; set; }
|
||||||
|
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ namespace FurnitureAssembly_Storekeeper_Contracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class MaterialBindingModel : IMaterial
|
public class MaterialBindingModel : IMaterial
|
||||||
{
|
{
|
||||||
public string MaterialName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
public IScope scope { get; set; } = new ScopeBindingModel();
|
public IScope Scope { get; set; } = new ScopeBindingModel();
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace FurnitureAssembly_Storekeeper_Contracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class RoleBindingModel : IRole
|
public class RoleBindingModel : IRole
|
||||||
{
|
{
|
||||||
public string RoleName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Id {get; set;}
|
public int Id {get; set;}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace FurnitureAssembly_Storekeeper_Contracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class ScopeBindingModel : IScope
|
public class ScopeBindingModel : IScope
|
||||||
{
|
{
|
||||||
public string ScopeName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace FurnitureAssembly_Storekeeper_Contracts.SearchModels
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? FurnitureName { get; set; }
|
public string? FurnitureName { get; set; }
|
||||||
|
public int? UserId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,6 @@ namespace FurnitureAssembly_Storekeeper_Contracts.SearchModels
|
|||||||
|
|
||||||
public string? Login { get; set; }
|
public string? Login { get; set; }
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
|
public int? RoleId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ namespace FurnitureAssembly_Storekeeper_Contracts.ViewModels
|
|||||||
public class FurnitureViewModel : IFurniture
|
public class FurnitureViewModel : IFurniture
|
||||||
{
|
{
|
||||||
[DisplayName("Название изделия")]
|
[DisplayName("Название изделия")]
|
||||||
public string FurnitureName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена изделия")]
|
[DisplayName("Цена изделия")]
|
||||||
public double FurnitureCost { get; set; }
|
public double Cost { get; set; }
|
||||||
[DisplayName("Дата создания")]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ namespace FurnitureAssembly_Storekeeper_Contracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class MaterialViewModel : IMaterial
|
public class MaterialViewModel : IMaterial
|
||||||
{
|
{
|
||||||
public string MaterialName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
|
|
||||||
public IScope scope { get; set; } = new ScopeViewModel();
|
public IScope Scope { get; set; } = new ScopeViewModel();
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace FurnitureAssembly_Storekeeper_Contracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class RoleViewModel : IRole
|
public class RoleViewModel : IRole
|
||||||
{
|
{
|
||||||
public string RoleName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace FurnitureAssembly_Storekeeper_Contracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ScopeViewModel : IScope
|
public class ScopeViewModel : IScope
|
||||||
{
|
{
|
||||||
public string ScopeName { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FurnitureAssemblyStorekeeperDatabaseImplement.Enums
|
||||||
|
{
|
||||||
|
public enum PaymentType
|
||||||
|
{
|
||||||
|
Неизвестен = -1,
|
||||||
|
Наличными = 0,
|
||||||
|
Картой = 1,
|
||||||
|
Смешанный = 2
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,8 @@ namespace FurnitureAssembly_Storekeeper_DataModels.Models
|
|||||||
{
|
{
|
||||||
public interface IFurniture : IId
|
public interface IFurniture : IId
|
||||||
{
|
{
|
||||||
string FurnitureName { get; }
|
string Name { get; }
|
||||||
double FurnitureCost { get; }
|
double Cost { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
Dictionary<int, (IMaterial, int)> FurnitureMaterials { get; }
|
Dictionary<int, (IMaterial, int)> FurnitureMaterials { get; }
|
||||||
IUser User { get; }
|
IUser User { get; }
|
||||||
|
@ -8,8 +8,8 @@ namespace FurnitureAssembly_Storekeeper_DataModels.Models
|
|||||||
{
|
{
|
||||||
public interface IMaterial : IId
|
public interface IMaterial : IId
|
||||||
{
|
{
|
||||||
string MaterialName { get; }
|
string Name { get; }
|
||||||
double Cost { get; }
|
double Cost { get; }
|
||||||
IScope scope { get; }
|
IScope Scope { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ namespace FurnitureAssembly_Storekeeper_DataModels.Models
|
|||||||
{
|
{
|
||||||
public interface IRole : IId
|
public interface IRole : IId
|
||||||
{
|
{
|
||||||
string RoleName { get; }
|
string Name { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ namespace FurnitureAssembly_Storekeeper_DataModels.Models
|
|||||||
{
|
{
|
||||||
public interface IScope : IId
|
public interface IScope : IId
|
||||||
{
|
{
|
||||||
string ScopeName { get; }
|
string Name { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureAssembly_Storekeeper_DataModels.Models
|
namespace FurnitureAssembly_Storekeeper_DataModels.Models
|
||||||
{
|
{
|
||||||
public interface IUser
|
public interface IUser : IId
|
||||||
{
|
{
|
||||||
string Login { get;}
|
string Login { get;}
|
||||||
string Password { get;}
|
string Password { get;}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user