DBUpdate
This commit is contained in:
parent
a4e790d380
commit
0c18013245
@ -19,6 +19,7 @@ namespace DatabaseImplement.Models
|
|||||||
public virtual List<DetailProduct> DetailProducts { get; set; } = new();
|
public virtual List<DetailProduct> DetailProducts { get; set; } = new();
|
||||||
[ForeignKey("DetailId")]
|
[ForeignKey("DetailId")]
|
||||||
public virtual List<DetailProduction> DetailProductions { get; set; } = new();
|
public virtual List<DetailProduction> DetailProductions { get; set; } = new();
|
||||||
|
public virtual Implementer User { get; set; }
|
||||||
public static Detail? Create(DetailBindingModel model)
|
public static Detail? Create(DetailBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -1,12 +1,71 @@
|
|||||||
using System;
|
using Contracts.BindingModels;
|
||||||
using System.Collections.Generic;
|
using Contracts.ViewModels;
|
||||||
using System.Linq;
|
using DataModels.Models;
|
||||||
using System.Text;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Threading.Tasks;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace DatabaseImplement.Models
|
namespace DatabaseImplement.Models
|
||||||
{
|
{
|
||||||
internal class Implementer
|
public class Implementer : IImplementerModel
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Login { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set;} = string.Empty;
|
||||||
|
[ForeignKey("UserId")]
|
||||||
|
public virtual List<Detail> Details { get; set; } = new();
|
||||||
|
[ForeignKey("UserId")]
|
||||||
|
public virtual List<Product> Products { get; set; } = new();
|
||||||
|
[ForeignKey("UserId")]
|
||||||
|
public virtual List<Production> Productions { get; set; } = new();
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Email = model.Email,
|
||||||
|
Name = model.Name,
|
||||||
|
Login = model.Login,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Implementer Create(ImplementerViewModel model)
|
||||||
|
{
|
||||||
|
return new Implementer
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Email = model.Email,
|
||||||
|
Name = model.Name,
|
||||||
|
Login = model.Login,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ImplementerBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return;
|
||||||
|
Email = model.Email;
|
||||||
|
Name = model.Name;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
public ImplementerViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
Email = Email,
|
||||||
|
Name = Name,
|
||||||
|
Login = Login,
|
||||||
|
Password = Password
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ namespace DatabaseImplement.Models
|
|||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
public virtual Implementer User { get; set; }
|
||||||
private Dictionary<int, (IDetailModel, int)>? _detailProducts = null;
|
private Dictionary<int, (IDetailModel, int)>? _detailProducts = null;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IDetailModel, int)> DetailProducts
|
public Dictionary<int, (IDetailModel, int)> DetailProducts
|
||||||
@ -43,7 +44,7 @@ namespace DatabaseImplement.Models
|
|||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Cost = model.Cost,
|
Cost = model.Cost,
|
||||||
UserId = model.UserId,
|
UserId = model.UserId,
|
||||||
Details = model.DetailProducts.Select(x => new DetailProduct
|
Details = model.ProductDetails.Select(x => new DetailProduct
|
||||||
{
|
{
|
||||||
Detail = context.Details.First(y => y.Id == x.Key),
|
Detail = context.Details.First(y => y.Id == x.Key),
|
||||||
Count = x.Value.Item2
|
Count = x.Value.Item2
|
||||||
|
@ -31,10 +31,9 @@ namespace DatabaseImplement.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[ForeignKey("ProductionId")]
|
[ForeignKey("ProductionId")]
|
||||||
public List<DetailProduction> Details { get; set; }
|
public List<DetailProduction> Details { get; set; } = new();
|
||||||
|
|
||||||
[ForeignKey("UserId")]
|
|
||||||
public virtual Implementer User { get; set; }
|
public virtual Implementer User { get; set; }
|
||||||
|
|
||||||
public static Production Create(FactoryGoWorkDatabase context, ProductionBindingModel model)
|
public static Production Create(FactoryGoWorkDatabase context, ProductionBindingModel model)
|
||||||
{
|
{
|
||||||
return new Production()
|
return new Production()
|
||||||
|
Loading…
Reference in New Issue
Block a user