Merge branch 'Lab6_Base' into Lab7_Base

This commit is contained in:
Данияр Аглиуллов 2023-03-13 23:28:43 +04:00
commit ac219be3bf
3 changed files with 19 additions and 3 deletions

View File

@ -66,8 +66,15 @@ namespace ConfectioneryListImplement
public ClientViewModel? Insert(ClientBindingModel model)
{
model.Id = _source.Clients.Count > 0 ? _source.Clients.Max(x => x.Id) + 1 : 1;
var res = Client.Create(model);
model.Id = 1;
foreach (var client in _source.Clients)
{
if (model.Id <= client.Id)
{
model.Id = client.Id + 1;
}
}
var res = Client.Create(model);
if (res != null)
{
_source.Clients.Add(res);

View File

@ -82,7 +82,14 @@ namespace ConfectioneryListImplement
public ImplementerViewModel? Insert(ImplementerBindingModel model)
{
model.Id = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.Id) + 1 : 1;
model.Id = 1;
foreach (var implementer in _source.Implementers)
{
if (model.Id <= implementer.Id)
{
model.Id = implementer.Id + 1;
}
}
var res = Implementer.Create(model);
if (res != null)
{

View File

@ -89,7 +89,9 @@ namespace ConfectioneryDatabaseImplement.Models
return new()
{
PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty,
ClientId = ClientId,
ClientFIO = Client?.ClientFIO ?? string.Empty,
ImplementerId = ImplementerId,
ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
PastryId = PastryId,
Count = Count,