правочка

This commit is contained in:
Максим Яковлев 2024-05-05 20:57:17 +04:00
parent 0fc71da489
commit 3a9732fc22

View File

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