예제 #1
0
        public IActionResult AddRouteInStops(int id, RoutesStops routesStops)
        {
            var routeStop = _stops.GetRouteStop(id, routesStops.RouteId);

            if (routeStop == null)
            {
                _stops.AddRouteInStops(id, routesStops.RouteId);

                if (_stops.GetRouteStop(id, routesStops.RouteId) != null)
                {
                    routesStops.StopId = id;
                    return(Created(HttpContext.Request.Scheme + "//" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + routesStops.StopId, routesStops));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(Ok($"Relationship between route {id} and stop {routesStops.RouteId} already exists"));
            }
        }