Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string ExportPrisonersByCells(SoftJailDbContext context, int[] ids)
- {
- var prisoners = context.Prisoners.Where(x => ids.Any(i => i == x.Id))
- .ToArray()
- .Select(p => new
- {
- Id= p.Id,
- Name = p.FullName,
- CellNumber = p.Cell.CellNumber,
- Officers = p.PrisonerOfficers.Select(o =>new ExportOfficerDto
- {
- OfficerName=o.Officer.FullName,
- Department=o.Officer.Department.Name
- }).OrderBy(o=>o.OfficerName)
- .ToArray(),
- TotalOfficerSalary=Math.Round(p.PrisonerOfficers.Sum(o=>o.Officer.Salary),2)
- })
- .OrderBy(p=>p.Name).ThenBy(p=>p.Id)
- .ToArray();
- string result = JsonConvert.SerializeObject(prisoners, Formatting.Indented);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment