public async Task <IEnumerable <ContestEvent> > GetContestEvents() { var contests = await _contestRepository.GetAll(); var contestEvents = _mapper.Map <List <ContestEvent> >(contests); return(contestEvents); }
public IActionResult Index(int?page) { var lst = _contestRepository.GetAll().ToList(); int pageSize = 4; var goodList = lst.Select(prop => { prop.Duration = (prop.EndDate - prop.StartDate).TotalHours; return(prop); }).ToList(); var currentUserLoggedIn = User.Identity.Name; if (User.Identity.Name == null || User.IsInRole("Admin")) { //admin or not registered, see all contest return(View(PaginatedList <Contest> .CreateAsync(goodList, page ?? 1, pageSize))); } var userInformation = _userInformation.GetUserInformationByUsername(currentUserLoggedIn); var clasa = string.Empty; if (userInformation != null) { clasa = userInformation.Clasa; } var contestForThisClass = goodList.Where(cst => cst.Content.Contains(clasa)).FirstOrDefault(); if (contestForThisClass != null) { return(View(PaginatedList <Contest> .CreateAsync(new List <Contest>() { contestForThisClass }, page ?? 1, pageSize))); } return(View(PaginatedList <Contest> .CreateAsync(goodList, page ?? 1, pageSize))); }
public async Task <IEnumerable <ContestResponseModel> > GetContests() { var contests = await _repository.GetAll(); return(_mapper.Map <IEnumerable <ContestResponseModel> >(contests)); }
public IEnumerable <Contest> GetAll() { return(contestRepository.GetAll()); }