public HttpResponseMessage AddRoute([FromBody] Route route) { if (ModelState.IsValid) { RoutesSample.AddRoute(route.RouteName, route.Points); return(new HttpResponseMessage(HttpStatusCode.OK)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); }
public HttpResponseMessage AddRankingEntry([FromBody] RankingEntryDetails rankingEntryDetails) { if (ModelState.IsValid) { Contestant contestant = ContestantsSample.GetContestant(rankingEntryDetails.ContestantId); Route route = RoutesSample.GetRoute(rankingEntryDetails.RouteId); RankingEntriesSample.AddRankingEntry(contestant, route); return(new HttpResponseMessage(HttpStatusCode.OK)); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); }
public HttpResponseMessage DeleteRoute(int id) { try { RoutesSample.DeleteRoute(id); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (RouteNotFoundException e) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } }
public HttpResponseMessage GetRoute(long id) { try { Route route = RoutesSample.GetRoute(id); return(Request.CreateResponse(HttpStatusCode.OK, route)); } catch (RouteNotFoundException e) { //TODO: logowanie wyjątków! return(new HttpResponseMessage(HttpStatusCode.NotFound)); } }
public HttpResponseMessage UpdateRouteInfo(long id, [FromBody] Route route) { if (ModelState.IsValid) { try { Route updatedRoute = RoutesSample.UpdateRouteInfo(id, route.RouteName, route.Points); return(Request.CreateResponse(HttpStatusCode.OK, updatedRoute)); } catch (RouteNotFoundException e) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); }
public HttpResponseMessage GetAllRoutes() { List <Route> sortedRoutes = RoutesSample.GetAllRoutes().OrderBy(r => r.RouteName).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, sortedRoutes)); }