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

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,
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()
@ -58,16 +69,11 @@ namespace AsbCloudInfrastructure.Services
var items = db.RelationContactsWells
.Where(x => x.IdWell == idWell && x.User.Company.IdCompanyType == contactTypeId);
var wellContacts = new List<RelationContactWell>();
foreach (var userId in userIds)
var wellContacts = userIds.Select(userId => new RelationContactWell()
{
var wellContact = new RelationContactWell()
{
IdWell = idWell,
IdUser = userId,
};
wellContacts.Add(wellContact);
}
IdWell = idWell,
IdUser = userId,
});
db.RelationContactsWells.RemoveRange(items);
db.RelationContactsWells.AddRange(wellContacts);