public async Task <IEnumerable <PilotDto> > GetPilots() { long userid = (long)this.Context.Request.Session["UserId"]; var pilots = await _pilotRepo.GetAll(userid); return(pilots.Select(x => Mapper.Map <PilotDto>(x))); }
private async Task updateNotifications(long userid, UserDataDto data) { var pilots = await _pilotRepo.GetAll(userid); foreach (var p in pilots) { var pd = data.Pilots.FirstOrDefault(x => x.Name == p.Name); Debug.Assert(pd != null); var actualManufacturingCount = data.Jobs.Count(x => x.Owner == p.Name && x.IsManufacturing); var actualResearchCount = data.Jobs.Count(x => x.Owner == p.Name && !x.IsManufacturing); if (p.FreeManufacturingJobsNofificationCount > 0) { if (actualManufacturingCount >= pd.MaxManufacturingJobs) { _logger.Debug("{method} resetting notification", "JobRepo::updateNotifications"); await _pilotRepo.SetFreeManufacturingJobsNofificationCount(p.PilotId, 0); // reset notification - maximum number of jobs running } } else { if (actualManufacturingCount < pd.MaxManufacturingJobs) { // notify about free manufacturing slots _logger.Debug("{method} scheduling man notification for {pilot}", "JobRepo::updateNotifications", p.Name); await _notificationRepo.IssueNew(userid, p.Name, $"{pd.MaxManufacturingJobs - actualManufacturingCount} free manufacturing slots"); await _pilotRepo.SetFreeManufacturingJobsNofificationCount(p.PilotId, 1); } } if (p.FreeResearchJobsNofificationCount > 0) { if (actualResearchCount >= pd.MaxResearchJobs) { _logger.Debug("{method} resetting notification", "JobRepo::updateNotifications"); await _pilotRepo.SetFreeResearchJobsNofificationCount(p.PilotId, 0); // reset notification - maximum number of jobs running } } else { if (actualResearchCount < pd.MaxResearchJobs) { // notify about free research slots _logger.Debug("{method} scheduling research notification for {pilot}", "JobRepo::updateNotifications", p.Name); await _notificationRepo.IssueNew(userid, p.Name, $"{pd.MaxResearchJobs - actualResearchCount} free research slots"); await _pilotRepo.SetFreeResearchJobsNofificationCount(p.PilotId, 1); } } } }
public async Task <List <KeyInfoDto> > Get(long userid) { var keys = await _keyInfoRepo.GetKeys(userid); var pilots = await _pilotRepo.GetAll(userid); var corpos = await _corporationRepo.GetAll(userid); var result = keys.GroupBy(x => x.KeyInfoId).Select(group => group.First()).Select(Mapper.Map <KeyInfoDto>).ToList(); foreach (var r in result) { r.Pilots = pilots.Where(p => p.KeyInfoId == r.KeyInfoId).Select(Mapper.Map <PilotDto>).ToList(); r.Corporations = corpos.Where(c => c.KeyInfoId == r.KeyInfoId).Select(Mapper.Map <CorporationDto>).ToList(); } return(result); }