Esempio n. 1
0
        public ActionResult LoadGRN(Guid id)
        {
            var delivery          = _deliveryService.Get(t => t.DispatchID == id).FirstOrDefault();
            var deliveryViewModel = new GRNViewModel();

            if (delivery != null)
            {
                deliveryViewModel = BindDeliveryViewModel(delivery);
                var deliveryDetail =
                    _deliveryDetailService.Get(t => t.DeliveryID == delivery.DeliveryID, null, "Commodity,Unit,Delivery").
                    FirstOrDefault();
                if (deliveryDetail != null)
                {
                    deliveryViewModel.DeliveryID       = deliveryDetail.DeliveryID;
                    deliveryViewModel.CommodityID      = deliveryDetail.CommodityID;
                    deliveryViewModel.UnitID           = deliveryDetail.UnitID;
                    deliveryViewModel.SentQuantity     = deliveryDetail.SentQuantity.ToQuintal();
                    deliveryViewModel.ReceivedQuantity = deliveryDetail.ReceivedQuantity.ToQuintal();
                    deliveryViewModel.Commodity        = deliveryDetail.Commodity.Name;
                    deliveryViewModel.Unit             = deliveryDetail.Unit.Name;
                    deliveryViewModel.DeliveryBy       = deliveryDetail.Delivery.DriverName;
                }
            }
            else
            {
                deliveryViewModel.RefNo = _transporterPaymentRequestService.Get().OrderByDescending(d => d.TransporterPaymentRequestID).Select(s => s.ReferenceNo).FirstOrDefault();
                var dispatchObj = _dispatchService.FindBy(t => t.DispatchID == id).FirstOrDefault();
                if (dispatchObj != null)
                {
                    var dispatchDetail = dispatchObj.DispatchDetails.FirstOrDefault();
                    if (dispatchDetail != null)
                    {
                        //deliveryViewModel.SentQuantity = dispatchDetail.RequestedQunatityInUnit;
                        deliveryViewModel.SentQuantity = dispatchDetail.RequestedQuantityInMT.ToQuintal(); //chahge to quintal. they receive using only quintal
                        deliveryViewModel.UnitID       = dispatchDetail.UnitID;
                        deliveryViewModel.Unit         = "Quintal";                                        //They always want to receive using quintal// _unitService.FindById(int.Parse(dispatchDetail.UnitID.ToString())).Name;
                    }
                    deliveryViewModel.CommodityID = dispatchObj.DispatchAllocation.CommodityID;
                    deliveryViewModel.Commodity   = dispatchObj.DispatchAllocation.Commodity.Name;
                    if (dispatchObj.DispatchAllocation.Unit != 0)
                    {
                    }
                    deliveryViewModel.DeliveryBy = dispatchObj.DriverName;
                }
            }
            deliveryViewModel.DispatchID = id;
            var firstOrDefault = _dispatchService.FindBy(t => t.DispatchID == id).FirstOrDefault();

            if (firstOrDefault != null)
            {
                deliveryViewModel.InvoiceNo = firstOrDefault.GIN;
            }

            return(Json(deliveryViewModel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult LoadGRN(Guid id)
        {
            var delivery          = _deliveryService.Get(t => t.DispatchID == id).FirstOrDefault();
            var deliveryViewModel = new GRNViewModel();

            if (delivery != null)
            {
                deliveryViewModel = BindDeliveryViewModel(delivery);
                var deliveryDetail =
                    _deliveryDetailService.Get(t => t.DeliveryID == delivery.DeliveryID, null, "Commodity,Unit,Delivery").
                    FirstOrDefault();
                if (deliveryDetail != null)
                {
                    deliveryViewModel.DeliveryID       = deliveryDetail.DeliveryID;
                    deliveryViewModel.CommodityID      = deliveryDetail.CommodityID;
                    deliveryViewModel.UnitID           = deliveryDetail.UnitID;
                    deliveryViewModel.SentQuantity     = deliveryDetail.SentQuantity;
                    deliveryViewModel.ReceivedQuantity = deliveryDetail.ReceivedQuantity;
                    deliveryViewModel.Commodity        = deliveryDetail.Commodity.Name;
                    deliveryViewModel.Unit             = deliveryDetail.Unit.Name;
                    deliveryViewModel.DeliveryBy       = deliveryDetail.Delivery.DriverName;
                }
            }
            else
            {
                var dispatchObj = _dispatchService.FindBy(t => t.DispatchID == id).FirstOrDefault();
                if (dispatchObj != null)
                {
                    var dispatchDetail = dispatchObj.DispatchDetails.FirstOrDefault();
                    if (dispatchDetail != null)
                    {
                        deliveryViewModel.SentQuantity = dispatchDetail.RequestedQunatityInUnit;
                    }
                    deliveryViewModel.CommodityID = dispatchObj.DispatchAllocation.CommodityID;
                    deliveryViewModel.Commodity   = dispatchObj.DispatchAllocation.Commodity.Name;
                    if (dispatchObj.DispatchAllocation.Unit != 0)
                    {
                        deliveryViewModel.UnitID = dispatchObj.DispatchAllocation.Unit;
                        deliveryViewModel.Unit   = _unitService.FindById(int.Parse(dispatchObj.DispatchAllocation.Unit.ToString())).Name;
                    }
                    deliveryViewModel.DeliveryBy = dispatchObj.DriverName;
                }
            }
            deliveryViewModel.DispatchID = id;
            var firstOrDefault = _dispatchService.FindBy(t => t.DispatchID == id).FirstOrDefault();

            if (firstOrDefault != null)
            {
                deliveryViewModel.InvoiceNo = firstOrDefault.GIN;
            }
            return(Json(deliveryViewModel, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult RecentDispatches()
        {
            var currentUser = UserAccountHelper.GetUser(HttpContext.User.Identity.Name);

            if (currentUser.DefaultHub != null)
            {
                var result     = _dispatchService.FindBy(m => m.HubID == currentUser.DefaultHub).OrderByDescending(m => m.DispatchID);
                var dispatched = GetDispatch(result);
                return(Json(dispatched, JsonRequestBehavior.AllowGet));
            }

            return(Json(null, JsonRequestBehavior.AllowGet));
        }