Ejemplo n.º 1
0
        private bool UpdateDonationPlan(DonationViewModel donationViewModel, int shippinInstructionId)
        {
            try
            {
                var index    = 0;
                var donation = _donationPlanDetailService.FindBy(s => s.DonationPlanHeader.ShippingInstructionId == shippinInstructionId).ToList();

                if (donation.Count > 0)
                {
                    var detailArray = donationViewModel.DonationPlanDetails.ToArray();
                    foreach (var donationPlanDetail in donation)
                    {
                        donationPlanDetail.DonationPlanHeader.AllocationDate        = DateTime.Now;
                        donationPlanDetail.DonationPlanHeader.CommodityID           = donationViewModel.CommodityID;
                        donationPlanDetail.DonationPlanHeader.DonorID               = donationViewModel.DonorID;
                        donationPlanDetail.DonationPlanHeader.ETA                   = donationPlanDetail.DonationPlanHeader.ETA;
                        donationPlanDetail.DonationPlanHeader.IsCommited            = false;
                        donationPlanDetail.DonationPlanHeader.ProgramID             = donationViewModel.ProgramID;
                        donationPlanDetail.DonationPlanHeader.ShippingInstructionId = shippinInstructionId;
                        donationPlanDetail.DonationPlanHeader.DonatedAmount         = donationViewModel.WieghtInMT;
                        donationPlanDetail.DonationPlanHeader.CommodityTypeID       = donationViewModel.CommodityTypeID;

                        donationPlanDetail.AllocatedAmount = detailArray[index].AllocatedAmount;
                        donationPlanDetail.ReceivedAmount  = detailArray[index].ReceivedAmount;
                        donationPlanDetail.Balance         = detailArray[index].Balance;
                        donationPlanDetail.HubID           = detailArray[index].HubID;
                        // donationPlanDetail.DonationPlanHeader = donation;
                        _donationPlanDetailService.EditDonationPlanDetail(donationPlanDetail);
                        index++;
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }