Пример #1
0
        private DispatchAllocationViewModelDto BindDispatchAllocationViewModelDto(DispatchAllocation dispatchAllocation)
        {
            var target = new DispatchAllocationViewModelDto();

            target.Amount                 = dispatchAllocation.Amount;
            target.AmountInUnit           = dispatchAllocation.AmountInUnit;
            target.BidRefNo               = dispatchAllocation.BidRefNo;
            target.CommodityID            = dispatchAllocation.CommodityID;
            target.CommodityName          = dispatchAllocation.Commodity.Name;
            target.DispatchAllocationID   = dispatchAllocation.DispatchAllocationID;
            target.DispatchedAmount       = dispatchAllocation.DispatchedAmount;
            target.DispatchedAmountInUnit = dispatchAllocation.DispatchedAmountInUnit;
            target.FDPName                = dispatchAllocation.FDP.Name;
            target.IsClosed               = dispatchAllocation.IsClosed;
            target.ProjectCodeID          = dispatchAllocation.ProjectCodeID;
            //TODO:Check Region,zone,woreda Name
            target.Region = dispatchAllocation.FDP.AdminUnit.AdminUnit2.Name;
            target.RemainingQuantityInQuintals = dispatchAllocation.RemainingQuantityInQuintals;
            target.RemainingQuantityInUnit     = dispatchAllocation.RemainingQuantityInUnit;
            target.RequisitionNo         = dispatchAllocation.RequisitionNo;
            target.ShippingInstructionID = dispatchAllocation.ShippingInstructionID;
            target.TransporterName       = dispatchAllocation.Transporter.Name;
            target.Woreda = dispatchAllocation.FDP.AdminUnit.Name;
            target.Zone   = dispatchAllocation.FDP.AdminUnit.AdminUnit2.Name;
            return(target);
        }
Пример #2
0
        private DispatchAllocationViewModel GetAllocationModelForClose(DispatchAllocation dispatch)
        {
            //TODO:Make sure if includeproperties are loaded correctly
            var fdp              = _fdpService.FindById(dispatch.FDPID);
            var donorid          = (dispatch.DonorID) ?? -1;
            var donor            = (donorid != -1) ? _donorService.FindById(donorid).Name : "-";
            var monthid          = (dispatch.Month) ?? -1;
            var month            = (monthid != -1) ? Cats.Helpers.RequestHelper.MonthName(monthid) : "-";
            var projectcodeId    = (dispatch.ProjectCodeID) ?? -1;
            var projectcodevalue = (projectcodeId != -1) ? _projectCodeService.GetProjectCodeValueByProjectCodeId(projectcodeId) : "-";
            DispatchAllocationViewModel model = new DispatchAllocationViewModel(fdp);

            model.Amount                      = dispatch.Amount;
            model.BidRefNo                    = dispatch.BidRefNo;
            model.FDPName                     = dispatch.FDP.Name;
            model.RequisitionNo               = dispatch.RequisitionNo;
            model.Round                       = dispatch.Round;
            model.Year                        = dispatch.Year;
            model.ProgramName                 = dispatch.Program.Name;
            model.CommodityName               = dispatch.Commodity.Name;
            model.MonthName                   = month;
            model.ShippingInstruction         = dispatch.ShippingInstruction;
            model.ProjectCodeValue            = projectcodevalue;
            model.RemainingQuantityInQuintals = dispatch.RemainingQuantityInQuintals;
            return(model);
        }
Пример #3
0
        /// <summary>
        /// Gets the allocation model.
        /// </summary>
        /// <param name="dispatch">The dispatch.</param>
        /// <returns></returns>
        private DispatchAllocation GetAllocationModel(DispatchAllocationViewModel dispatch)
        {
            DispatchAllocation model = new 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);
        }
Пример #4
0
        private DispatchAllocationViewModel GetAllocationModel(DispatchAllocation dispatch)
        {
            //TODO:Make sure if includeproperties are loaded correctly
            var fdp = _fdpService.FindById(dispatch.FDPID);
            DispatchAllocationViewModel model = new 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);
        }
Пример #5
0
        public ActionResult SelectionHeader(string requisition)
        {
            DispatchAllocation dispatchAllocation =
                _dispatchAllocationService.GetAllocations(requisition).FirstOrDefault();

            return(PartialView(dispatchAllocation));
        }
Пример #6
0
        public ActionResult Edit(string id)
        {
            DispatchAllocation          allocation = _dispatchAllocationService.FindById(Guid.Parse(id));
            DispatchAllocationViewModel alloc      = GetAllocationModel(allocation);

            alloc.CommodityTypeID = allocation.Commodity.CommodityTypeID;
            PrepareEdit(alloc);
            return(PartialView("Edit", alloc));
        }
Пример #7
0
        public ActionResult Close(string id)
        {
            //var closeAllocation = _dispatchAllocationService.FindById(Guid.Parse(id));
            //return PartialView("Close", closeAllocation);
            DispatchAllocation          allocation = _dispatchAllocationService.FindById(Guid.Parse(id));
            DispatchAllocationViewModel alloc      = GetAllocationModelForClose(allocation);

            return(PartialView("Close", alloc));
        }
Пример #8
0
 public bool DeleteDispatchAllocation(DispatchAllocation dispatchAllocation)
 {
     if (dispatchAllocation == null)
     {
         return(false);
     }
     _unitOfWork.DispatchAllocationRepository.Delete(dispatchAllocation);
     _unitOfWork.Save();
     return(true);
 }
Пример #9
0
 public ActionResult SaveFDPAllocationAjax(DispatchAllocationViewModel allocation)
 {
     if (ModelState.IsValid)
     {
         DispatchAllocation alloc = GetAllocationModel(allocation);
         _dispatchAllocationService.EditDispatchAllocation(alloc);
         return(Json("{status:1}", JsonRequestBehavior.AllowGet));
     }
     return(Json("{status:0}", JsonRequestBehavior.AllowGet));
 }
 /// <summary>
 /// Attaches the transaction group.
 /// </summary>
 /// <param name="allocation">The allocation.</param>
 /// <param name="TransactionGroupID">The transaction group ID.</param>
 /// <returns></returns>
 public bool AttachTransactionGroup(DispatchAllocation allocation, int TransactionGroupID)
 {
     DispatchAllocation original =
         _unitOfWork.DispatchAllocationRepository.Get(
             p => p.DispatchAllocationID == allocation.DispatchAllocationID).SingleOrDefault();
     if (original != null)
     {
         //original.TransactionGroupID = TransactionGroupID;
         _unitOfWork.Save();
         return true;
     }
     return false;
 }
Пример #11
0
        /// <summary>
        /// Attaches the transaction group.
        /// </summary>
        /// <param name="allocation">The allocation.</param>
        /// <param name="TransactionGroupID">The transaction group ID.</param>
        /// <returns></returns>
        public bool AttachTransactionGroup(DispatchAllocation allocation, int TransactionGroupID)
        {
            DispatchAllocation original =
                _unitOfWork.DispatchAllocationRepository.Get(
                    p => p.DispatchAllocationID == allocation.DispatchAllocationID).SingleOrDefault();

            if (original != null)
            {
                //original.TransactionGroupID = TransactionGroupID;
                _unitOfWork.Save();
                return(true);
            }
            return(false);
        }
Пример #12
0
        public bool CommitDispatchAllocation(Guid AllocationId, int SIID, int ProjectCodeID)
        {
            DispatchAllocation all =
                _unitOfWork.DispatchAllocationRepository.Get(p => p.DispatchAllocationID == AllocationId).
                SingleOrDefault();

            if (all != null)
            {
                all.ShippingInstructionID = SIID;
                all.ProjectCodeID         = ProjectCodeID;
                _unitOfWork.Save();
                return(true);
            }
            return(false);
        }
Пример #13
0
 public ActionResult Edit(DispatchAllocationViewModel allocation)
 {
     if (ModelState.IsValid)
     {
         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));
 }
Пример #14
0
        private DispatchAllocationViewModel GetAllocationModel(DispatchAllocation dispatch)
        {
            //TODO:Make sure if includeproperties are loaded correctly
            var fdp     = _fdpService.FindById(dispatch.FDPID);
            var donorid = (dispatch.DonorID) ?? -1;
            var donor   = (donorid != -1) ? _donorService.FindById(donorid).Name : "-";
            var monthid = (dispatch.Month) ?? -1;
            var month   = (monthid != -1) ? Cats.Helpers.RequestHelper.MonthName(monthid) : "-";
            DispatchAllocationViewModel model = new 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;
            model.ProgramName       = dispatch.Program.Name;
            model.CommodityTypeName = dispatch.Commodity.CommodityType.Name;
            model.CommodityName     = dispatch.Commodity.Name;
            model.DonorName         = donor;
            model.UnitName          = _unitService.FindById(dispatch.Unit) == null ? "-" : _unitService.FindById(dispatch.Unit).Name;
            model.MonthName         = month;
            model.TransporterName   = dispatch.Transporter.Name;
            return(model);
        }
Пример #15
0
 public bool EditDispatchAllocation(DispatchAllocation dispatchAllocation)
 {
     _unitOfWork.DispatchAllocationRepository.Edit(dispatchAllocation);
     _unitOfWork.Save();
     return(true);
 }
 public bool DeleteDispatchAllocation(DispatchAllocation dispatchAllocation)
 {
     if (dispatchAllocation == null) return false;
     _unitOfWork.DispatchAllocationRepository.Delete(dispatchAllocation);
     _unitOfWork.Save();
     return true;
 }
 public bool AddDispatchAllocation(DispatchAllocation dispatchAllocation)
 {
     _unitOfWork.DispatchAllocationRepository.Add(dispatchAllocation);
     _unitOfWork.Save();
     return true;
 }
Пример #18
0
        //
        // GET: /Dispatch/Create

        public ActionResult Create(string ginNo, int type)
        {
            ViewBag.Units = _unitService.GetAllUnit();

            var dispatch = _dispatchService.GetDispatchByGIN(ginNo);
            var user     = _userProfileService.GetUser(User.Identity.Name);

            if (dispatch != null)
            {
                if (user.DefaultHub != null && user.DefaultHub.HubID == dispatch.HubID)
                {
                    PrepareEdit(dispatch, user, type);
                    var transaction = _dispatchService.GetDispatchTransaction(dispatch.DispatchID);
                    var dis         = DispatchModel.GenerateDispatchModel(dispatch, transaction);
                    return(View(dis));
                }
                PrepareCreate(type);
                var comms = new List <DispatchDetailModel>();
                ViewBag.SelectedCommodities = comms;
                var theViewModel = new DispatchModel {
                    Type = type, DispatchDetails = comms
                };
                ViewBag.Message = "The selected GIN Number doesn't exist on your default warehouse. Try changing your default warehouse.";
                return(View(theViewModel));
            }
            else
            {
                PrepareCreate(type);
                var comms = new List <DispatchDetailModel>();
                ViewBag.SelectedCommodities = comms;
                var theViewModel = new DispatchModel {
                    Type = type, DispatchDetails = comms
                };

                if (Request["type"] != null && Request["allocationId"] != null)
                {
                    var allocationId     = Guid.Parse(Request["allocationId"]);
                    var allocationTypeId = Convert.ToInt32(Request["type"]);

                    if (allocationTypeId == 1)//to FDP
                    {
                        DispatchAllocation toFDPDispatchAllocation = _dispatchAllocationService.FindById(allocationId);

                        theViewModel.FDPID = toFDPDispatchAllocation.FDPID;
                        PrepareFDPForEdit(toFDPDispatchAllocation.FDPID);

                        theViewModel.RequisitionNo = toFDPDispatchAllocation.RequisitionNo;
                        theViewModel.BidNumber     = toFDPDispatchAllocation.BidRefNo;
                        theViewModel.SINumber      = toFDPDispatchAllocation.ShippingInstruction.Value;
                        theViewModel.ProjectNumber = toFDPDispatchAllocation.ProjectCode.Value;

                        theViewModel.CommodityTypeID = toFDPDispatchAllocation.Commodity.CommodityTypeID;
                        ViewBag.CommodityTypeID      = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name", toFDPDispatchAllocation.Commodity.CommodityTypeID);

                        if (toFDPDispatchAllocation.ProgramID.HasValue)
                        {
                            theViewModel.ProgramID = toFDPDispatchAllocation.ProgramID.Value;
                            ViewBag.ProgramID      = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name", theViewModel.ProgramID);
                        }
                        if (toFDPDispatchAllocation.TransporterID.HasValue)
                        {
                            theViewModel.TransporterID = toFDPDispatchAllocation.TransporterID.Value;
                        }
                        ViewBag.TransporterID = new SelectList(_transporterService.GetAllTransporter(), "TransporterID", "Name", theViewModel.TransporterID);
                        if (toFDPDispatchAllocation.Year.HasValue)
                        {
                            theViewModel.Year = toFDPDispatchAllocation.Year.Value;
                        }
                        var years = (from y in _periodService.GetYears()
                                     select new { Name = y, Id = y }).ToList();
                        ViewBag.Year = new SelectList(years, "Id", "Name");
                        ViewBag.Year = new SelectList(years, "Id", "Name", theViewModel.Year);
                        if (toFDPDispatchAllocation.Month.HasValue)
                        {
                            theViewModel.Month = toFDPDispatchAllocation.Month.Value;
                        }
                        var months = (from y in _periodService.GetMonths(theViewModel.Year)
                                      select new { Name = y, Id = y }).ToList();
                        ViewBag.Month = new SelectList(months, "Id", "Name", theViewModel.Month);
                        if (toFDPDispatchAllocation.Round.HasValue)
                        {
                            theViewModel.Round = toFDPDispatchAllocation.Round.Value;
                        }
                        theViewModel.DispatchAllocationID = toFDPDispatchAllocation.DispatchAllocationID;
                    }
                    else //allocationTypeId == 2
                    {
                        var otherDispatchAllocation = _otherDispatchAllocationService.FindById(allocationId);
                        theViewModel.ToHubID       = otherDispatchAllocation.ToHubID;
                        theViewModel.SINumber      = otherDispatchAllocation.ShippingInstruction.Value;
                        theViewModel.ProjectNumber = otherDispatchAllocation.ProjectCode.Value;
                        theViewModel.ProgramID     = otherDispatchAllocation.ProgramID;

                        theViewModel.CommodityTypeID = otherDispatchAllocation.Commodity.CommodityTypeID;
                        ViewBag.CommodityTypeID      = new SelectList(_commodityTypeService.GetAllCommodityType(), "CommodityTypeID", "Name", otherDispatchAllocation.Commodity.CommodityTypeID);

                        ViewBag.ProgramID = new SelectList(_programService.GetAllProgram(), "ProgramID", "Name", theViewModel.ProgramID);
                        theViewModel.OtherDispatchAllocationID = otherDispatchAllocation.OtherDispatchAllocationID;
                    }
                }

                return(View(theViewModel));
            }
        }