PIbd-21 Yakovlev M.G. lab work 7 #10

Closed
YakovlevMaxim wants to merge 7 commits from Lab7_Base into Lab6_Base
Showing only changes of commit 3a9732fc22 - Show all commits

View File

@ -38,7 +38,7 @@ namespace CarRepairShopDatabaseImplement.Implements
using var context = new CarRepairShopDatabase();
model.ClientId = context.Clients.FirstOrDefault(x => x.Email.Equals(model.SenderName))?.Id;
var message = MessageInfo.Create(model);
if(message == null) return null;
if(message == null || context.Messages.Any(x => x.MessageId.Equals(model.MessageId))) return null;
context.Messages.Add(message);
context.SaveChanges();
return message.GetViewModel;