public async Task <RotaDictionary> GetRotaJobs(string rotaType) { IEnumerable <string> names = await GetNamesOnRota(rotaType); IEnumerable <RotaItemDto> rota = await _rotaRepo.GetSoughtedRota(rotaType); IOrderedEnumerable <DateTime> rotaDates = rota.Select(r => r.DateTime).Distinct().OrderBy(d => d); var rotaJobsDictionary = new RotaDictionary(); foreach (DateTime rotaDate in rotaDates) { var nameRoles = new NameRoles(); foreach (var name in names) { var roles = new List <string>(); var userRota = rota.Where(r => r.DateTime == rotaDate && r.Name == name).ToList(); userRota.ForEach(r => roles.Add(r.Role)); if (userRota.Count == 0) { roles.Add("--"); } nameRoles.KeyValues.Add(name, roles); } rotaJobsDictionary.DateNameJobListPairs.Add(rotaDate, nameRoles); } return(rotaJobsDictionary); }
public async Task <IActionResult> LoadProjectionRotaView() { RotaDictionary rotas = await _rotaService.GetRotaJobs(RotaType.Projection.ToString()); ViewData["names"] = (await _rotaService.GetNamesOnRota(RotaType.Projection.ToString())).ToList().OrderBy(n => n); ViewData["rota"] = rotas; ViewData["LeftMenuConfig"] = "Projection"; ViewData["Title"] = "Projection Rota"; return(View("RotaManagement")); }