public void Execute(SaveRouteRequest request)
        {
            if (request.Time <= 0)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, "It is required time bigger than 0");
            }
            if (request.Cost <= 0)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, "It is required cost bigger than 0");
            }

            request.PointFromCode = request.PointFromCode.ToLower();
            request.PointToCode   = request.PointToCode.ToLower();

            Route route = _routeData.GetRoute(request.PointFromCode, request.PointToCode);

            if (route != null)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, "The route already exists");
            }

            route = new Route
            {
                PointFromCode = request.PointFromCode,
                PointToCode   = request.PointToCode,
                Cost          = request.Cost,
                Time          = request.Time,
            };

            _routeData.Save(route);
        }
        public void Execute(DeleteRouteRequest request)
        {
            Route route = _routeData.GetRoute(request.PointFromCode.ToLower(), request.PointToCode.ToLower());

            if (route is null)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, "The route id does not exist");
            }

            //TODO: Send Message to verify if the points associated have others routes or they aren't routes

            _routeData.Delete(route);
        }
        public void Execute(UpdateRouteRequest request)
        {
            if (!request.Time.HasValue && !request.Cost.HasValue)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, "Time or Cost have to be fill");
            }

            request.PointFromCode = request.PointFromCode.ToLower();
            request.PointToCode   = request.PointToCode.ToLower();

            Route route = _routeData.GetRoute(request.PointFromCode, request.PointToCode);

            if (route is null)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, "The route does not exist");
            }

            route.Cost = GetValue(request.Cost, route.Cost);
            route.Time = GetValue(request.Time, route.Time);

            _routeData.Update(route);
        }