public bool DeleteLoanReciptPlanDetail(LoanReciptPlanDetail entity)
 {
     if(entity==null) return false;
        _unitOfWork.LoanReciptPlanDetailRepository.Delete(entity);
        _unitOfWork.Save();
        return true;
 }
 public bool AddRecievedLoanReciptPlanDetail(LoanReciptPlanDetail loanReciptPlanDetail)
 {
     var loanReciptPlan = _unitOfWork.LoanReciptPlanRepository.FindById(loanReciptPlanDetail.LoanReciptPlanID);
     if (loanReciptPlan!=null)
     {
         _unitOfWork.LoanReciptPlanDetailRepository.Add(loanReciptPlanDetail);
         var reciptAllocaltion = new ReceiptAllocation()
             {
                 ReceiptAllocationID = Guid.NewGuid(),
                 PartitionID = 0,
                 IsCommited = false,
                 ETA = loanReciptPlan.CreatedDate,
                 ProjectNumber = loanReciptPlan.ProjectCode,
                 CommodityID = loanReciptPlan.CommodityID,
                 CommoditySourceID = loanReciptPlan.CommoditySourceID,
                 SINumber = loanReciptPlan.ShippingInstruction.Value,
                 QuantityInMT = loanReciptPlanDetail.RecievedQuantity,
                 HubID = loanReciptPlanDetail.HubID,
                 //SourceHubID = loanReciptPlan.SourceHubID,
                 ProgramID = loanReciptPlan.ProgramID,
                 IsClosed = false
             };
         _unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);
         _unitOfWork.Save();
         return true;
     }
     return false;
 }
        public bool AddRecievedLoanReciptPlanDetail(LoanReciptPlanDetail loanReciptPlanDetail)
        {
            var loanReciptPlan = _unitOfWork.LoanReciptPlanRepository.FindById(loanReciptPlanDetail.LoanReciptPlanID);
            if (loanReciptPlan!=null)
            {
                var parentID = _unitOfWork.CommodityRepository.FindById(loanReciptPlan.CommodityID).ParentID ??
                                 loanReciptPlan.CommodityID;

                _unitOfWork.LoanReciptPlanDetailRepository.Add(loanReciptPlanDetail);
                //var reciptAllocaltion = new ReceiptAllocation()
                //    {
                //        ReceiptAllocationID = Guid.NewGuid(),
                //        PartitionId = 0,
                //        IsCommited = false,
                //        ETA = loanReciptPlan.CreatedDate,
                //        ProjectNumber = loanReciptPlan.ProjectCode,
                //        CommodityID = parentID,//loanReciptPlan.CommodityID,
                //        CommoditySourceID = loanReciptPlan.CommoditySourceID,
                //        SINumber = loanReciptPlan.ShippingInstruction.Value,
                //        QuantityInMT = loanReciptPlanDetail.RecievedQuantity,
                //        HubID = loanReciptPlanDetail.HubID,
                //        //SourceHubID = loanReciptPlan.SourceHubID,
                //        DonorID = int.Parse(loanReciptPlan.LoanSource),
                //        ProgramID = loanReciptPlan.ProgramID,
                //        IsClosed = false,
                //        IsFalseGRN = loanReciptPlan.IsFalseGRN
                //    };
                //_unitOfWork.ReceiptAllocationReository.Add(reciptAllocaltion);
                _unitOfWork.Save();
                return true;
            }
            return false;
        }
 public bool EditLoanReciptPlanDetail(LoanReciptPlanDetail entity)
 {
     _unitOfWork.LoanReciptPlanDetailRepository.Edit(entity);
        _unitOfWork.Save();
        return true;
 }
 public ActionResult ReciptPlan(LoanReciptPlanWithDetailViewModel loanReciptPlanDetail)
 {
     var userID = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).UserProfileID;
     if (ModelState.IsValid && loanReciptPlanDetail!=null)
     {
         var loanReciptPlanModel = new LoanReciptPlanDetail()
             {
                 LoanReciptPlanID = loanReciptPlanDetail.LoanReciptPlanID,
                 HubID = loanReciptPlanDetail.HubID,
                 //MemoReferenceNumber = loanReciptPlanDetail.MemoRefrenceNumber,
                 RecievedQuantity = loanReciptPlanDetail.Amount,
                 RecievedDate = DateTime.Today,
                 ApprovedBy = userID
             };
         _loanReciptPlanDetailService.AddRecievedLoanReciptPlanDetail(loanReciptPlanModel);
         return RedirectToAction("Detail", new {id = loanReciptPlanDetail.LoanReciptPlanID});
     }
     ViewBag.HubID = new SelectList(_commonService.GetAllHubs(), "HubID", "Name");
     return View(loanReciptPlanDetail);
 }