forked from ddrilling/AsbCloudServer
WellContactService.GetAsync user mapping
This commit is contained in:
parent
447478836b
commit
5d5fe21c91
@ -22,7 +22,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
public async Task<IEnumerable<CompanyWithUsersDto>> GetAsync(int wellId, int contactTypeId, CancellationToken token)
|
public async Task<IEnumerable<CompanyWithUsersDto>> GetAsync(int wellId, int contactTypeId, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
|
||||||
var query = db.Companies
|
var query = db.Companies
|
||||||
.Where(c => c.IdCompanyType == contactTypeId)
|
.Where(c => c.IdCompanyType == contactTypeId)
|
||||||
.Where(c => c.RelationCompaniesWells.Any(rc => rc.IdWell == wellId))
|
.Where(c => c.RelationCompaniesWells.Any(rc => rc.IdWell == wellId))
|
||||||
@ -30,7 +29,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()
|
||||||
@ -75,21 +85,5 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return await db.SaveChangesAsync(token)
|
return await db.SaveChangesAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UserContactDto Convert(User u, int wellId)
|
|
||||||
{
|
|
||||||
return 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)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user