Правки по ревью

This commit is contained in:
Olga Nemt 2023-06-23 12:13:17 +05:00
parent 447478836b
commit 2925e56876
2 changed files with 16 additions and 10 deletions

View File

@ -30,7 +30,18 @@ namespace AsbCloudInfrastructure.Services
{ {
Caption = c.Caption, Caption = c.Caption,
Id = c.Id, Id = c.Id,
Users = c.Users.Select(user => Convert(user, wellId)) Users = c.Users.Select(u => new UserContactDto()
{
Id = u.Id,
Name = u.Name,
Patronymic = u.Patronymic,
Surname = u.Surname,
Company = u.Company.Adapt<CompanyDto>(),
Email = u.Email,
Phone = u.Phone,
Position = u.Position,
IsContact = u.RelationContactsWells.Any(rel => rel.IdWell == wellId)
})
}); });
var entities = await query.AsNoTracking() var entities = await query.AsNoTracking()
@ -58,16 +69,11 @@ namespace AsbCloudInfrastructure.Services
var items = db.RelationContactsWells var items = db.RelationContactsWells
.Where(x => x.IdWell == idWell && x.User.Company.IdCompanyType == contactTypeId); .Where(x => x.IdWell == idWell && x.User.Company.IdCompanyType == contactTypeId);
var wellContacts = new List<RelationContactWell>(); var wellContacts = userIds.Select(userId => new RelationContactWell()
foreach (var userId in userIds)
{
var wellContact = new RelationContactWell()
{ {
IdWell = idWell, IdWell = idWell,
IdUser = userId, IdUser = userId,
}; });
wellContacts.Add(wellContact);
}
db.RelationContactsWells.RemoveRange(items); db.RelationContactsWells.RemoveRange(items);
db.RelationContactsWells.AddRange(wellContacts); db.RelationContactsWells.AddRange(wellContacts);