public IHttpActionResult CreateStopPointRide(StopPointRide stopPointRide) { //Checks data annotations in model class StopPointRide if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } stopPointRidesRepository.Add(stopPointRide); stopPointRidesRepository.SaveChanges(); return(Created(new Uri(Request.RequestUri + "/" + stopPointRide.Id), stopPointRide)); }
public IHttpActionResult UpdateStopPointRide(int id, StopPointRide stopPointRide) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } var existingStopPointRide = stopPointRidesRepository.GetById(id); if (existingStopPointRide != null) { existingStopPointRide.Location = stopPointRide.Location; existingStopPointRide.LeavingTime = stopPointRide.LeavingTime; stopPointRidesRepository.SaveChanges(); } else { return(NotFound()); } return(Ok()); }