public async Task<List<EstheticianAdminViewModel>> GetEstheticianMasterListAsync() { var estheticians = await _estheticians.GetAsync(x => x.User, x => x.Services); var list = new List<EstheticianAdminViewModel>(); foreach (var esthetician in estheticians) { var toAdd = new EstheticianAdminViewModel { Id = esthetician.Id, FirstName = esthetician.User.FirstName, LastName = esthetician.User.LastName, Services = new List<SpaServiceViewModel>(), Color = esthetician.Color }; foreach (var service in esthetician.Services) toAdd.Services.Add(new SpaServiceViewModel { Id = service.Id, Name = service.Name }); list.Add(toAdd); } return list; }
public async Task<EstheticianAdminViewModel> GetByIdAsync(int id) { var esthetician = await _estheticians.GetByIdAsync(id, x => x.User, x => x.Services, x => x.Shifts); var businessDays = _businessDays.FindAsync(x => esthetician.Shifts.Select(s => s.BusinessDayId).Contains(x.Id)); var retVal = new EstheticianAdminViewModel { Id = esthetician.Id, FirstName = esthetician.User.FirstName, LastName = esthetician.User.LastName, Email = esthetician.User.Email, PhoneNumber = esthetician.User.PhoneNumber, Services = new List<SpaServiceViewModel>(), Color = esthetician.Color, Shifts = new List<ShiftViewModel>() }; foreach (var service in esthetician.Services) retVal.Services.Add(new SpaServiceViewModel { Id = service.Id, Name = service.Name }); var bdList = await businessDays; foreach (var shift in esthetician.Shifts) { var bd = bdList.Single(x => x.Id == shift.BusinessDayId); retVal.Shifts.Add(new ShiftViewModel { StartTime = shift.StartTime, EndTime = shift.EndTime, BusinessDay = new BusinessDayViewModel { OpeningTime = bd.OpeningTime, ClosingTime = bd.ClosingTime, Location = new LocationViewModel { Id = bd.LocationId, City = bd.LocationId == 1 ? "Stanton" : "Brea" } } }); } return retVal; }