Example #1
0
        public ActionResult TransportOrder_Read([DataSourceRequest] DataSourceRequest request, int id = 0, int programId = 0, int regionId = 0)
        {
            var transportRequistions = programId == 0 ?_transportRequisitionService.GetTransportRequsitionDetails(): _transportRequisitionService.GetTransportRequsitionDetails(programId);
            List <TransportOrder> transportRequisitionRegion;

            //var filteredTransportOrder=_transportOrderDetailService.FindBy(m=>m.RequisitionID=)
            var transportOrders = id == 0 ? _transportOrderService.GetFilteredTransportOrder(transportRequistions, (int)TransportOrderStatus.Draft).OrderByDescending(m => m.TransportOrderID).ToList()
                                          : _transportOrderService.GetFilteredTransportOrder(transportRequistions, id).ToList();


            transportRequisitionRegion = regionId == 0
                                             ? transportOrders
                                             : (from detail in transportOrders
                                                let orDefault = detail.TransportOrderDetails.FirstOrDefault()
                                                                where
                                                                orDefault != null &&
                                                                orDefault.FDP.AdminUnit.AdminUnit2.AdminUnit2.AdminUnitID ==
                                                                regionId
                                                                select detail).ToList();


            var datePref = UserAccountHelper.GetUser(User.Identity.Name).DatePreference;
            var statuses = _workflowStatusService.GetStatus(WORKFLOW.TRANSPORT_ORDER);
            var transportOrderViewModels = TransportOrderViewModelBinder.BindListTransportOrderViewModel(
                transportRequisitionRegion, datePref, statuses);

            return(Json(transportOrderViewModels.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }
        public ActionResult TransportOrder_Read([DataSourceRequest] DataSourceRequest request, int id = 0)
        {
            var datePref        = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference;
            var hubId           = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DefaultHub.HasValue ? _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DefaultHub.Value : 0;
            var transportOrders = id == 0 ? _transportOrderService.GetByHub(t => t.StatusID == (int)TransportOrderStatus.Draft, includeProperties: "TransportOrderDetails", hubId: hubId, statusId: (int)TransportOrderStatus.Draft)
                                  .OrderByDescending(m => m.TransportOrderID)
                                  .ToList() : _transportOrderService.GetByHub(t => t.StatusID == id, includeProperties: "TransportOrderDetails", hubId: hubId, statusId: id).ToList();

            //var transportOrders = id == 0 ? _transportOrderService.Get(t => t.StatusID == (int)TransportOrderStatus.Draft, includeProperties: "TransportOrderDetails")
            //    .OrderByDescending(m => m.TransportOrderID)
            //    .ToList() : _transportOrderService.Get(t => t.StatusID == id).ToList();

            var statuses = _workflowStatusService.GetStatus(WORKFLOW.TRANSPORT_ORDER);
            var transportOrderViewModels = TransportOrderViewModelBinder.BindListTransportOrderViewModel(
                transportOrders, datePref, statuses);

            return(Json(transportOrderViewModels.ToDataSourceResult(request), JsonRequestBehavior.AllowGet));
        }