Example #1
0
        public ActionResult GetAllocations(string RquisitionNo, int?CommodityID, bool Uncommited)
        {
            ViewBag.req        = RquisitionNo;
            ViewBag.Com        = CommodityID;
            ViewBag.Uncommited = Uncommited;
            var list = new List <BLL.DispatchAllocation>();

            BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name);
            if (!string.IsNullOrEmpty(RquisitionNo) && CommodityID.HasValue)
            {
                list = _dispatchAllocationService.GetAllocations(RquisitionNo, CommodityID.Value, user.DefaultHub.HubID, Uncommited, user.PreferedWeightMeasurment);
            }
            else if (!string.IsNullOrEmpty(RquisitionNo))
            {
                list = _dispatchAllocationService.GetAllocations(RquisitionNo, user.DefaultHub.HubID, Uncommited);
            }

            List <DispatchAllocationViewModelDto> FDPAllocations = new List <DispatchAllocationViewModelDto>();

            foreach (var dispatchAllocation in list)
            {
                var    DAVMD = new DispatchAllocationViewModelDto();
                string preferedWeightMeasurment = user.PreferedWeightMeasurment.ToUpperInvariant();
                //if (preferedWeightMeasurment == "MT" && dispatchAllocation.Commodity.CommodityTypeID == 1) //only for food
                //{
                //    DAVMD.Amount = dispatchAllocation.Amount / 10;
                //    DAVMD.DispatchedAmount = dispatchAllocation.DispatchedAmount / 10;
                //    DAVMD.RemainingQuantityInQuintals = dispatchAllocation.RemainingQuantityInQuintals / 10;
                //}
                //else
                {
                    DAVMD.Amount                      = dispatchAllocation.Amount;
                    DAVMD.DispatchedAmount            = dispatchAllocation.DispatchedAmount;
                    DAVMD.RemainingQuantityInQuintals = dispatchAllocation.RemainingQuantityInQuintals;
                }
                DAVMD.DispatchAllocationID  = dispatchAllocation.DispatchAllocationID;
                DAVMD.CommodityName         = dispatchAllocation.Commodity.Name;
                DAVMD.CommodityID           = dispatchAllocation.CommodityID;
                DAVMD.RequisitionNo         = dispatchAllocation.RequisitionNo;
                DAVMD.BidRefNo              = dispatchAllocation.BidRefNo;
                DAVMD.ProjectCodeID         = dispatchAllocation.ProjectCodeID;
                DAVMD.ShippingInstructionID = dispatchAllocation.ShippingInstructionID;

                DAVMD.Region          = dispatchAllocation.FDP.AdminUnit.AdminUnit2.AdminUnit2.Name;
                DAVMD.Zone            = dispatchAllocation.FDP.AdminUnit.AdminUnit2.Name;
                DAVMD.Woreda          = dispatchAllocation.FDP.AdminUnit.Name;
                DAVMD.FDPName         = dispatchAllocation.FDP.Name;
                DAVMD.TransporterName = dispatchAllocation.Transporter.Name;
                DAVMD.IsClosed        = dispatchAllocation.IsClosed;


                DAVMD.AmountInUnit            = DAVMD.Amount;
                DAVMD.DispatchedAmountInUnit  = dispatchAllocation.DispatchedAmountInUnit;
                DAVMD.RemainingQuantityInUnit = dispatchAllocation.RemainingQuantityInUnit;

                FDPAllocations.Add(DAVMD);
            }

            return(PartialView("AllocationList", FDPAllocations));
        }
Example #2
0
        public ActionResult JsonRegionZones(string requisitionNumber)
        {
            List <DispatchAllocation> allocations = _dispatchAllocationService.GetAllocations(requisitionNumber);

            if (allocations.Count > 0)
            {
                var firstOrDefault = allocations.FirstOrDefault();
                if (firstOrDefault != null)
                {
                    var region = firstOrDefault.FDP.AdminUnit.AdminUnit2.AdminUnit2.AdminUnitID;
                    var zone   = firstOrDefault.FDP.AdminUnit.AdminUnit2.AdminUnitID;
                    return(Json(new { region, zone }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }