Beispiel #1
0
        public Point Execute(GetPointByCodeQueryRequest request)
        {
            Point point = _pointData.GetPointByCode(request.Code);

            if (point == null)
            {
                throw new ResponseException(System.Net.HttpStatusCode.BadRequest, $"The point does not exist");
            }

            return(point);
        }
Beispiel #2
0
        public void Execute(DeletePointCommnadRequest request)
        {
            Point point = _pointData.GetPointByCode(request.Code);

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

            IEnumerable <string> allPointsCode = _pointData.GetAllPointCode();

            _pointData.Delete(request.Code);
            _routeData.DeleteRouteFromCode(request.Code);
            _routeData.DeleteRoutesWithPointCode(request.Code, allPointsCode);
        }
        public void Execute(UpdatePointRequest request)
        {
            request.Code = request.Code.ToLower();

            Point point = _pointdata.GetPointByCode(request.Code);

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

            point = new Point
            {
                Code        = request.Code,
                Description = request.Description
            };

            _pointdata.Update(point);
        }
        public void Execute(SavePointRequest request)
        {
            request.Code = request.Code.ToLower();

            Point point = _pointdata.GetPointByCode(request.Code);

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

            point = new Point
            {
                Code        = request.Code,
                Description = request.Description
            };

            _pointdata.Save(point);
        }