Example #1
0
        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));
        }
Example #2
0
        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());
        }