One more LINQ

This commit is contained in:
gg12 darfren 2024-03-17 11:13:42 +04:00
parent 1d0a220011
commit 4badbb1569

View File

@ -85,14 +85,10 @@ namespace IceCreamShopDatabaseImplement.Implements
if (model == null)
return null;
using var context = new IceCreamShopDataBase();
foreach (var iceCream in context.IceCreams)
{
if (iceCream.Id == model.IceCreamId)
{
model.IceCreamName = iceCream.IceCreamName;
break;
}
}
var iceCream = context.IceCreams.FirstOrDefault(x => (x.Id == model.IceCreamId));
if (iceCream == null)
return model;
model.IceCreamName = iceCream.IceCreamName;
return model;
}
}