public IHttpActionResult GetEdges() { string jsonBody; using (StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream)) { jsonBody = reader.ReadToEnd(); } EdgeRequest request; try { request = JsonConvert.DeserializeObject <EdgeRequest>(jsonBody); } catch (Exception e) { return(StatusCode(HttpStatusCode.BadRequest)); } IList <Edge> edges = db.GetAllEdges(); List <EdgeResponse> response = CreateOurResponse(edges, request.ParcelType, request.weight); if (!response.Any()) { return(StatusCode(HttpStatusCode.NoContent)); } return(Ok(response)); }
public ActionResult Home() { IList <Edge> edges; IList <City> cities2; using (var context = new TLContext()) { edges = context.GetAllEdges(); cities2 = context.GetCities().ToList(); } var cities = MappingService.GetCities(); var dtoCities = new List <CityDTO>(); foreach (var city in cities) { dtoCities.Add(new CityDTO() { Id = city.ID, Name = city.Name }); } var parcelTypes = MappingService.GetParcelTypes(); var dtoParcelTypes = new List <ParcelTypeDTO>(); foreach (var parcelType in parcelTypes) { dtoParcelTypes.Add(new ParcelTypeDTO() { Id = parcelType.ID, Name = parcelType.Name }); } var model = new HomeDTO { SourceCitites = dtoCities, DestinationCitites = dtoCities, ParcelTypes = dtoParcelTypes }; return(View(model)); }