Compare commits
2 Commits
2a30f03682
...
26a687363e
Author | SHA1 | Date | |
---|---|---|---|
|
26a687363e | ||
|
4fe042017b |
@ -7,6 +7,6 @@ namespace ComputerHardwareStoreContracts.BindingModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public int StoreKeeperId { get; set; }
|
public IStoreKeeperModel StoreKeeper { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@ namespace ComputerHardwareStoreContracts.ViewModels
|
|||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
public int StoreKeeperId { get; set; }
|
public IStoreKeeperModel StoreKeeper { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
double Cost { get; }
|
double Cost { get; }
|
||||||
int StoreKeeperId { get; }
|
IStoreKeeperModel StoreKeeper { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,9 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int StoreKeeperId { get; private set; }
|
|
||||||
public virtual StoreKeeper? StoreKeeper { get; set; }
|
public virtual StoreKeeper? StoreKeeper { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
IStoreKeeperModel IComponentModel.StoreKeeper => throw new NotImplementedException();
|
||||||
|
|
||||||
[ForeignKey("ComponentId")]
|
[ForeignKey("ComponentId")]
|
||||||
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
public virtual List<ProductComponent> ProductComponents { get; set; } = new();
|
||||||
@ -30,7 +31,7 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Cost = model.Cost,
|
Cost = model.Cost,
|
||||||
StoreKeeper = context.StoreKeepers.First(x => x.Id == model.StoreKeeperId)
|
StoreKeeper = context.StoreKeepers.First(x => x.Id == model.StoreKeeper.Id)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update (ComponentBindingModel model)
|
public void Update (ComponentBindingModel model)
|
||||||
|
@ -58,18 +58,25 @@ namespace ComputerHardwareStoreDatabaseImplement.Models
|
|||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Cost = model.Cost,
|
Cost = model.Cost,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
Builds = model.PurchaseBuilds.Select(x =>
|
Builds = context.Builds
|
||||||
new PurchaseBuild
|
.Where(b => model.PurchaseBuilds.ContainsKey(b.Id))
|
||||||
|
.Select(b => new PurchaseBuild()
|
||||||
{
|
{
|
||||||
Build = context.Builds.First(y => y.Id == x.Key),
|
PurchaseId = model.Id,
|
||||||
Count = x.Value.Item2
|
BuildId = b.Id,
|
||||||
|
Build = b,
|
||||||
|
Count = model.PurchaseProducts[b.Id].Item2
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
Products = model.PurchaseProducts.Select(x =>
|
Products = context.Products
|
||||||
new PurchaseProduct
|
.Where(p => model.PurchaseProducts.ContainsKey(p.Id))
|
||||||
|
.Select (p => new PurchaseProduct()
|
||||||
{
|
{
|
||||||
Product = context.Products.First(z => z.Id == z.Key),
|
PurchaseId = model.Id,
|
||||||
Count = x.Value.Item2
|
ProductId = p.Id,
|
||||||
}).ToList()
|
Product = p,
|
||||||
|
Count = model.PurchaseProducts[p.Id].Item2
|
||||||
|
})
|
||||||
|
.ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(PurchaseBindingModel model)
|
public void Update(PurchaseBindingModel model)
|
||||||
|
Loading…
Reference in New Issue
Block a user