Exemplo n.º 1
0
        public IActionResult AddStop(CreatedStop createdStop)
        {
            if (createdStop.DepartureTime > createdStop.ArrivalTime)
            {
                return(BadRequest());
            }
            TimeSpan duration = createdStop.ArrivalTime - createdStop.DepartureTime;

            createdStop.Duration = duration.TotalSeconds;
            int  idOfNewElement = _stops.AddStop(createdStop);
            Stop stop           = createdStop.ToStop();

            stop.StopId = idOfNewElement;

            stop.Duration = duration.TotalSeconds;

            return(Created(HttpContext.Request.Scheme + "//" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + idOfNewElement, stop));
        }
Exemplo n.º 2
0
        public int AddStop(CreatedStop createdStop)
        {
            Stop stop = createdStop.ToStop();

            return(_stopRepository.Insert(stop.ToEntity()));
        }