Exemple #1
0
        /// <summary>
        /// Gets the allocation model.
        /// </summary>
        /// <param name="dispatch">The dispatch.</param>
        /// <returns></returns>
        private BLL.DispatchAllocation GetAllocationModel(BLL.ViewModels.DispatchAllocationViewModel dispatch)
        {
            BLL.DispatchAllocation model = new BLL.DispatchAllocation();
            model.Amount      = dispatch.Amount;
            model.Beneficiery = dispatch.Beneficiery;
            model.BidRefNo    = dispatch.BidRefNo;
            model.CommodityID = dispatch.CommodityID;
            if (dispatch.DispatchAllocationID.HasValue)
            {
                model.DispatchAllocationID = dispatch.DispatchAllocationID.Value;
            }

            model.DonorID               = dispatch.DonorID;
            model.FDPID                 = dispatch.FDPID;
            model.HubID                 = dispatch.HubID;
            model.Month                 = dispatch.Month;
            model.PartitionID           = dispatch.PartitionID;
            model.ProgramID             = dispatch.ProgramID;
            model.ProjectCodeID         = dispatch.ProjectCodeID;
            model.RequisitionNo         = dispatch.RequisitionNo;
            model.Round                 = dispatch.Round;
            model.ShippingInstructionID = dispatch.ShippingInstructionID;
            model.TransporterID         = dispatch.TransporterID;
            model.Unit = dispatch.Unit;
            model.Year = dispatch.Year;
            return(model);
        }
Exemple #2
0
        private BLL.ViewModels.DispatchAllocationViewModel GetAllocationModel(BLL.DispatchAllocation dispatch)
        {
            //TODO:Make sure if includeproperties are loaded correctly
            var fdp = _fdpService.FindById(dispatch.FDPID);

            BLL.ViewModels.DispatchAllocationViewModel model = new BLL.ViewModels.DispatchAllocationViewModel(fdp);
            model.Amount               = dispatch.Amount;
            model.Beneficiery          = dispatch.Beneficiery;
            model.BidRefNo             = dispatch.BidRefNo;
            model.CommodityID          = dispatch.CommodityID;
            model.DispatchAllocationID = dispatch.DispatchAllocationID;
            model.DonorID              = dispatch.DonorID;
            model.FDPID                 = dispatch.FDPID;
            model.HubID                 = dispatch.HubID;
            model.Month                 = dispatch.Month;
            model.PartitionID           = dispatch.PartitionID;
            model.ProgramID             = dispatch.ProgramID;
            model.ProjectCodeID         = dispatch.ProjectCodeID;
            model.RequisitionNo         = dispatch.RequisitionNo;
            model.Round                 = dispatch.Round;
            model.ShippingInstructionID = dispatch.ShippingInstructionID;
            model.TransporterID         = dispatch.TransporterID;
            model.Unit            = dispatch.Unit;
            model.Year            = dispatch.Year;
            model.CommodityTypeID = dispatch.Commodity.CommodityTypeID;
            return(model);
        }
Exemple #3
0
 public ActionResult Edit(BLL.ViewModels.DispatchAllocationViewModel allocation)
 {
     if (ModelState.IsValid)
     {
         BLL.DispatchAllocation alloc = GetAllocationModel(allocation);
         _dispatchAllocationService.EditDispatchAllocation(alloc);
         if (this.Request.UrlReferrer != null)
         {
             return(Redirect(Request.UrlReferrer.PathAndQuery));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
         //return Json(true, JsonRequestBehavior.AllowGet);
         //return RedirectToAction("Index");
     }
     PrepareEdit(allocation);
     return(PartialView(allocation));
 }
Exemple #4
0
 public ActionResult Create(BLL.ViewModels.DispatchAllocationViewModel allocation)
 {
     if (ModelState.IsValid)
     {
         var user  = _userProfileService.GetUser(User.Identity.Name);
         var alloc = GetAllocationModel(allocation);
         alloc.HubID = user.DefaultHub.HubID;
         _dispatchAllocationService.AddDispatchAllocation(alloc);
         if (this.Request.UrlReferrer != null)
         {
             return(Redirect(Request.UrlReferrer.PathAndQuery));
         }
         else
         {
             return(RedirectToAction("Index"));
         }
     }
     PrepareEdit(allocation);
     return(PartialView("Create", allocation));
 }
Exemple #5
0
        private void PrepareEdit(BLL.ViewModels.DispatchAllocationViewModel allocation)
        {
            ViewBag.Commodities = new SelectList(_commonService.GetAllParents(), "CommodityID", "Name", allocation.CommodityID);

            ViewBag.CommodityTypes = new SelectList(_commonService.GetAllCommodityType(), "CommodityTypeID", "Name", allocation.CommodityTypeID);

            ViewBag.Donors = new SelectList(_commonService.GetAllDonors(), "DonorID", "Name", allocation.DonorID);

            ViewBag.Years = new SelectList(_commonService.GetYears().Select(y => new { Name = y, Id = y }), "Id", "Name", allocation.Year);
            if (allocation.Year.HasValue)
            {
                ViewBag.Months = new SelectList(_commonService.GetMonths(allocation.Year.Value).Select(p => new{ Id = p, Name = p }), "Id", "Name", allocation.Month);
            }
            else
            {
                ViewBag.Months = new SelectList(Enumerable.Empty <SelectListItem>(), "Id", "Name");
            }
            ViewBag.Transporters = new SelectList(_transporterService.GetAllTransporter(), "TransporterID", "Name", allocation.TransporterID);
            ViewBag.Programs     = new SelectList(_commonService.GetAllProgram(), "ProgramID", "Name", allocation.ProgramID);
            ViewBag.Units        = new SelectList(_commonService.GetAllUnit(), "UnitID", "Name", allocation.Unit);

            // TODO we can use the line below for debugging and server side validation
            PrepareFDPForEdit(allocation.FDPID);
        }
 private BLL.ViewModels.DispatchAllocationViewModel GetAllocationModel(BLL.DispatchAllocation dispatch)
 {
     //TODO:Make sure if includeproperties are loaded correctly
     var fdp = _fdpService.FindById(dispatch.FDPID);
     BLL.ViewModels.DispatchAllocationViewModel model = new BLL.ViewModels.DispatchAllocationViewModel(fdp);
     model.Amount = dispatch.Amount;
     model.Beneficiery = dispatch.Beneficiery;
     model.BidRefNo = dispatch.BidRefNo;
     model.CommodityID = dispatch.CommodityID;
     model.DispatchAllocationID = dispatch.DispatchAllocationID;
     model.DonorID = dispatch.DonorID;
     model.FDPID = dispatch.FDPID;
     model.HubID = dispatch.HubID;
     model.Month = dispatch.Month;
     model.PartitionID = dispatch.PartitionID;
     model.ProgramID = dispatch.ProgramID;
     model.ProjectCodeID = dispatch.ProjectCodeID;
     model.RequisitionNo = dispatch.RequisitionNo;
     model.Round = dispatch.Round;
     model.ShippingInstructionID = dispatch.ShippingInstructionID;
     model.TransporterID = dispatch.TransporterID;
     model.Unit = dispatch.Unit;
     model.Year = dispatch.Year;
     model.CommodityTypeID = dispatch.Commodity.CommodityTypeID;
     return model;
 }