Ejemplo n.º 1
0
        public ActionResult Create(string receiptAllocationId)
        {
            if (String.IsNullOrEmpty(receiptAllocationId))
            {
                return(View());
            }
            _receiptAllocationId = Guid.Parse(receiptAllocationId);

            var receiptAllocation = _receiptAllocationService.FindById(_receiptAllocationId);

            var user = _userProfileService.GetUser(User.Identity.Name);

            if (receiptAllocation == null ||
                (user.DefaultHub == null || receiptAllocation.HubID != user.DefaultHub.Value))
            {
                return(View());
            }

            var viewModel = _receiveService.ReceiptAllocationToReceive(receiptAllocation);

            viewModel.CurrentHub    = user.DefaultHub.Value;
            viewModel.UserProfileId = user.UserProfileID;
            var hubOwner = _hub.FindById(user.DefaultHub.Value);

            viewModel.IsTransporterDetailVisible = !hubOwner.HubOwner.Name.Contains("WFP");
            viewModel.AllocationStatusViewModel  = _receiveService.GetAllocationStatus(_receiptAllocationId);
            //var commodities = _commodityService.GetAllCommodityViewModelsByParent(receiptAllocation.CommodityID);
            //ViewData["commodities"] = commodities;
            //ViewData["units"] = _unitService.GetAllUnitViewModels();
            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public ReceiveNewViewModel ModeltoNewView(Receive receive) //string receiveId, string grn)
        {
            var receiptAllocation = _receiptAllocationService.FindById(receive.ReceiptAllocationID.GetValueOrDefault());

            var user = _userProfileService.GetUser(User.Identity.Name);

            var viewModel = _receiveService.ReceiptAllocationToReceive(receiptAllocation);

            viewModel.CurrentHub    = user.DefaultHub.Value;
            viewModel.UserProfileId = user.UserProfileID;
            var hubOwner = _hub.FindById(user.DefaultHub.Value);

            viewModel.IsTransporterDetailVisible = !hubOwner.HubOwner.Name.Contains("WFP");
            viewModel.AllocationStatusViewModel  = _receiveService.GetAllocationStatus(receive.ReceiptAllocationID.GetValueOrDefault());
            //var commodities = _commodityService.GetAllCommodityViewModelsByParent(receiptAllocation.CommodityID);
            //ViewData["commodities"] = commodities;
            //ViewData["units"] = _unitService.GetAllUnitViewModels();


            viewModel.Grn                 = receive.GRN;
            viewModel.ReceiptDate         = receive.ReceiptDate;
            viewModel.SiNumber            = receiptAllocation.SINumber;
            viewModel.ReceiptDate         = viewModel.ReceiptDate;
            viewModel.ReceiptAllocationId = receive.ReceiptAllocationID.GetValueOrDefault();
            viewModel.ReceiveId           = receive.ReceiveID;

            //viewModel.StackNumber
            viewModel.WayBillNo   = receive.WayBillNo;
            viewModel.SiNumber    = receiptAllocation.SINumber;
            viewModel.ProjectCode = receiptAllocation.ProjectNumber;
            //viewModel.Program = .FindById(receiptAllocation.ProgramID).Name;
            viewModel.ProgramId = receiptAllocation.ProgramID;
            //viewModel.CommodityType = _CommodityTypeRepository.FindById(receiptAllocation.Commodity.CommodityTypeID).Name,
            viewModel.CommodityTypeId       = receiptAllocation.Commodity.CommodityTypeID;
            viewModel.CommoditySourceTypeId = receiptAllocation.CommoditySourceID;


            if (CommoditySource.Constants.LOAN == receiptAllocation.CommoditySourceID ||
                CommoditySource.Constants.SWAP == receiptAllocation.CommoditySourceID ||
                CommoditySource.Constants.TRANSFER == receiptAllocation.CommoditySourceID ||
                CommoditySource.Constants.REPAYMENT == receiptAllocation.CommoditySourceID)
            {
                if (receiptAllocation.SourceHubID.HasValue)
                {
                    viewModel.SourceHub = _hub.FindById(receiptAllocation.SourceHubID.GetValueOrDefault(0)).Name;
                }
            }

            if (CommoditySource.Constants.LOCALPURCHASE == receiptAllocation.CommoditySourceID)
            {
                viewModel.SupplierName  = receiptAllocation.SupplierName;
                viewModel.PurchaseOrder = receiptAllocation.PurchaseOrder;
            }

            viewModel.CommoditySource       = receiptAllocation.CommoditySource.Name;
            viewModel.CommoditySourceTypeId = receiptAllocation.CommoditySourceID;
            viewModel.ReceivedByStoreMan    = receive.ReceivedByStoreMan;
            ReceiveDetail receivedetail = receive.ReceiveDetails.FirstOrDefault();

            viewModel.StoreId     = receive.StoreId.GetValueOrDefault();
            viewModel.StackNumber = receive.StackNumber.GetValueOrDefault();
            viewModel.ReceiveDetailNewViewModel = new ReceiveDetailNewViewModel
            {
                CommodityId          = receivedetail.CommodityID,
                CommodityChildID     = receivedetail.CommodityChildID,
                ReceivedQuantityInMt =
                    receivedetail.QuantityInMT,
                ReceivedQuantityInUnit =
                    receivedetail.QuantityInUnit,
                SentQuantityInMt   = receivedetail.SentQuantityInMT,
                SentQuantityInUnit = receivedetail.SentQuantityInUnit,
                UnitId             = receivedetail.UnitID,
                Description        = receivedetail.Description,
                ReceiveId          = receivedetail.ReceiveID,
                ReceiveDetailId    = receivedetail.ReceiveDetailID,
            };

            viewModel.WeightBridgeTicketNumber = receive.WeightBridgeTicketNumber;
            viewModel.WeightBeforeUnloading    = receive.WeightBeforeUnloading;
            viewModel.WeightAfterUnloading     = receive.WeightAfterUnloading;
            viewModel.TransporterId            = receive.TransporterID;
            viewModel.DriverName     = receive.DriverName;
            viewModel.PlateNoPrime   = receive.PlateNo_Prime;
            viewModel.PlateNoTrailer = receive.PlateNo_Trailer;
            viewModel.PortName       = receive.PortName;
            viewModel.Remark         = receive.Remark;

            return(viewModel);
        }