public HttpResponseMessage GetLastPassiveCompetitionsByRowCount(int rowCount) { //Retrieves Last {rowCount} competitions which are currently not active. var competitions = _repository.GetLastPassiveCompetitionsByRowCount(rowCount); CustomResponse response; if (competitions == null) { competitions = new List <Competition>(); } //Maps to DTO ICollection <CompetitionDTO> competitionDTOs = new List <CompetitionDTO>(); competitions.ForEach(c => competitionDTOs.Add(GenericMapper.MapToCompetitionDTO(c))); response = ResponseMessageHelper.CreateResponse(HttpStatusCode.OK, false, competitionDTOs, ConstantResponse.COMPETITION_PASSIVES_SUCCESS); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.OK, response)); }
public HttpResponseMessage Get(int competitionId) { //Gets the competition related with the given id var competition = _repository.GetById(competitionId); CustomResponse response; //Null check if (competition == null) { response = ResponseMessageHelper.CreateResponse(HttpStatusCode.NotFound, true, HttpStatusCode.NotFound, ConstantResponse.COMPETITION_RETRIEVE_BY_ID_NOT_FOUND); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.NotFound, response)); } //Mapping to DTO var competitionDTO = GenericMapper.MapToCompetitionDTO(competition); //Returns data response = ResponseMessageHelper.CreateResponse(HttpStatusCode.OK, false, competitionDTO, ConstantResponse.COMPETITION_RETRIEVE_BY_ID_SUCCESS); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.OK, response)); }
public HttpResponseMessage GetActiveCompetitions() { //Retrieves active comps from db var activeCompetitions = _repository.GetActiveCompetitions(); //Null check for Sanity ! if (activeCompetitions == null) { activeCompetitions = new List <Competition>(); } //Maps active comps to the dto ICollection <CompetitionDTO> competitionDTOs = new List <CompetitionDTO>(); activeCompetitions.ForEach(c => competitionDTOs.Add(GenericMapper.MapToCompetitionDTO(c))); //Returns data CustomResponse response = ResponseMessageHelper.CreateResponse(HttpStatusCode.OK, false, competitionDTOs, ConstantResponse.COMPETITION_RETRIEVE_SUCCESS); return(Request.CreateResponse <CustomResponse>(HttpStatusCode.OK, response)); }