решаем конфликты
This commit is contained in:
commit
d49014d810
@ -11,7 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreContra
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreBusinessLogic", "ComputerHardwareStoreBusinessLogic\ComputerHardwareStoreBusinessLogic.csproj", "{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreDatabaseImplement", "ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj", "{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerHardwareStoreDatabaseImplement", "ComputerHardwareStoreDatabaseImplement\ComputerHardwareStoreDatabaseImplement.csproj", "{09A57BE9-A653-4AAD-9FB2-1F8974F294CD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -35,10 +35,6 @@ Global
|
||||
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D32DEB60-AF40-46AF-8914-DC6A19BD66CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{93BD4E28-48D8-4D3A-87FB-FB96F00DA64B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -10,8 +10,6 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> CannedComponents { get; set; } = new();
|
||||
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents => throw new NotImplementedException();
|
||||
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ namespace ComputerHardwareStoreDatabaseImplement
|
||||
public virtual DbSet<Component> Components { set; get; }
|
||||
public virtual DbSet<Product> Products { set; get; }
|
||||
public virtual DbSet<ProductComponent> ProductComponents { set; get; }
|
||||
|
||||
public virtual DbSet<StoreKeeper> StoreKeepers { set; get; }
|
||||
public virtual DbSet<Build> Builds { set; get; }
|
||||
public virtual DbSet<OrderProduct> OrderProducts { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
|
||||
using ComputerHardwareStoreDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
{
|
||||
public class Build : IBuildModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[Required]
|
||||
public int VendorId { get; private set; }
|
||||
public virtual Vendor Vendor { get; private set; } = new();
|
||||
|
||||
[ForeignKey("BuildId")]
|
||||
public Dictionary<int, (IComponentModel, int)> BuildComponents => throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -13,9 +13,13 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
[Required]
|
||||
public int StoreKeeperId { get; private set; }
|
||||
public virtual StoreKeeper? StoreKeeper { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
||||
public static Component? Create(ComponentBindingModel model)
|
||||
public static Component? Create(ComputerHardwareStoreDBContext context, ComponentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -25,7 +29,8 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Cost = model.Cost
|
||||
Cost = model.Cost,
|
||||
StoreKeeper = context.StoreKeepers.First(x => x.Id == model.StoreKeeperId)
|
||||
};
|
||||
}
|
||||
public void Update (ComponentBindingModel model)
|
||||
@ -44,7 +49,5 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
Name = Name,
|
||||
Cost = Cost
|
||||
};
|
||||
|
||||
public int StoreKeeperId => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -78,5 +78,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
};
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> OrderProduct => throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -23,8 +23,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
if (_productComponents == null)
|
||||
{
|
||||
_productComponents = Components
|
||||
.ToDictionary(c => c.ComponentId, c =>
|
||||
(c.Component as IComponentModel, c.Count));
|
||||
.ToDictionary(c => c.ComponentId, c => (c.Component as IComponentModel, c.Count));
|
||||
}
|
||||
return _productComponents;
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
using ComputerHardwareStoreContracts.BindingModels;
|
||||
using ComputerHardwareStoreContracts.ViewModels;
|
||||
using ComputerHardwareStoreDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ComputerHardwareStoreDatabaseImplement.Models
|
||||
{
|
||||
public class StoreKeeper : IStoreKeeperModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
|
||||
public string Login { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
|
||||
public string Password { get; private set; } = string.Empty;
|
||||
|
||||
public static StoreKeeper? Create(ComputerHardwareStoreDBContext context, StoreKeeperBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new StoreKeeper()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Login = model.Login,
|
||||
Password = model.Password,
|
||||
};
|
||||
}
|
||||
public void Update(StoreKeeperBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Name = string.IsNullOrEmpty(model.Name) ? Name : model.Name;
|
||||
Password = string.IsNullOrEmpty(model.Password) ? Password : model.Password;
|
||||
}
|
||||
|
||||
public StoreKeeperViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Login = Login,
|
||||
Password = Password
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user