public async Task <IHttpActionResult> GetProblems(Guid districtId) { try { var problems = await DistrictCore.GetProblemsAsync(districtId); if (problems == null) { return(BadRequest("No problems found")); } IList <ProblemModel> result = problems.Select(problem => new ProblemModel() { Id = problem.Id, UserId = problem.UserId, Name = problem.Name, Description = problem.Description }).ToList(); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> GetAll(Guid districtId) { try { var district = await DistrictCore.GetAsync(districtId); if (district == null) { return(BadRequest("Invalid districtId")); } var problems = await SortAndComputePoints(district); return(Ok(problems)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> GetAll() { try { var districts = await DistrictCore.GetAllAsync(); if (districts == null) { return(BadRequest("No districts found")); } IList <DistrictModel> result = districts.Select(district => new DistrictModel() { Id = district.Id, Name = district.Name }).ToList(); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }