Example #1
0
 // GET: api/TransportRule
 protected virtual ActionResult <IEnumerable <TVM> > Get(
     ApiRequestParams requestParams
     )
 {
     try
     {
         // Some controllers return all records in DB, e.g. Schedule Rules
         if (requestParams.AllRecords)
         {
             return(Ok(new { data = service.GetAll()
                                    .Select(e => map.Map <TD, TVM>(e)) }));
         }
         var result = service.GetAll()
                      .Skip(requestParams.Skip)
                      .Take(requestParams.pageSize)
                      .Select(e => map.Map <TD, TVM>(e))
                      .AsEnumerable();
         //!!TODO Implement pagination and filtering
         var paginationMetaData = new PaginationMetaData();
         return(Ok(new { metaData = paginationMetaData, data = result }));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
        public Delivery Get(string fromDestination, string toDestination, int?packageWeight, string cargoType, int?packageLength, int?packageWidth, int?packageHeight, int?discount)
        {
            if (!packageWeight.HasValue || !packageLength.HasValue || !packageHeight.HasValue || !packageWeight.HasValue)
            {
                return(ReturnError());
            }
            ApiRequestParams apiRequestParams = new ApiRequestParams()
            {
                fromDestination = fromDestination,
                toDestination   = toDestination,
                packageWeight   = packageWeight.Value,
                cargoType       = cargoType,
                recorded        = "false",
                packageHeight   = packageHeight.Value,
                packageLength   = packageLength.Value,
                packageWidth    = packageWidth.Value
            };

            DeliveryData fastest  = Utilities.ShortestPathCalculator.ShortestPath(apiRequestParams, discount, "time");
            DeliveryData cheapest = Utilities.ShortestPathCalculator.ShortestPath(apiRequestParams, discount, "price");

            var delivery = new Delivery()
            {
                best     = fastest,
                cheapest = cheapest,
                fastest  = fastest
            };

            return(delivery);
        }
Example #3
0
        public override void HandlePost(HttpListenerContext ctx, WebUser user, string postData)
        {
            ApiRequestParams p = null;

            if ((p = TryJsonParse <ApiRequestParams>(ctx, postData)) == null)
            {
                return;
            }

            if (p.Action.Equals("status_get"))
            {
                WebAdmin.SendHtml(ctx, ToJson(new DefaultApiResponse(Core.Server.Status == ServerStatus.Online, Core.Config.EnableRuntime)));
            }
        }
        public new ActionResult <IEnumerable <EmployersList> > Get(
            [FromQuery] ApiRequestParams apiRequestParams
            )
        {
            var list = serv.GetIndexView(new viewOptions {
                displayLength = apiRequestParams.pageSize,
                displayStart  = apiRequestParams.Skip
            });

            if (list.query == null)
            {
                return(NotFound());
            }
            return(Ok(new { data = list.query }));
        }
        public DeliveryData Get(string fromDestination, string toDestination, int packageWeight, string cargoType, string recorded, int packageLength, int packageWidth, int packageHeight)
        {
            ApiRequestParams apiRequestParams = new ApiRequestParams()
            {
                fromDestination = fromDestination,
                toDestination   = toDestination,
                packageWeight   = packageWeight,
                cargoType       = cargoType,
                recorded        = recorded,
                packageHeight   = packageHeight,
                packageLength   = packageLength,
                packageWidth    = packageWidth
            };

            return(Utilities.ShortestPathCalculator.ShortestPathFlight(apiRequestParams, null));
        }
        public new ActionResult <WorkOrderVM> Get(
            [FromQuery] ApiRequestParams apiRequestParams)
        {
            var vo = new viewOptions();

            vo.displayLength = apiRequestParams.pageSize;
            vo.displayStart  = apiRequestParams.Skip;
            vo.employerGuid  = UserSubject;
            dataTableResult <DTO.WorkOrdersList> list = serv.GetIndexView(vo);

            MapperHelpers.ClientTimeZoneInfo = _clientTimeZoneInfo;

            var result = list.query
                         .Select(
                e => map.Map <DTO.WorkOrdersList, WorkOrderVM>(e)
                ).AsEnumerable();

            return(Ok(new { data = result }));
        }
Example #7
0
 public new ActionResult <IEnumerable <WorkerVM> > Get(
     [FromQuery] ApiRequestParams apiRequestParams)
 {
     return(base.Get(apiRequestParams));
 }
Example #8
0
 public new ActionResult <IEnumerable <WorkAssignmentVM> > Get(ApiRequestParams apiRequestParams)
 {
     return(base.Get(apiRequestParams));
 }