public ActionResult Create()
 {
     ViewBag.ProgramID = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name");
     ViewBag.CommodityID = new SelectList(_commonService.GetCommodities(), "CommodityID", "Name");
     ViewBag.CommodityTypeID = new SelectList(_commonService.GetCommodityTypes(), "CommodityTypeID", "Name");
     ViewBag.CommoditySourceID = new SelectList(_commonService.GetCommoditySource(), "CommoditySourceID", "Name");
     ViewBag.HubID = new SelectList(_commonService.GetAllHubs(), "HubID", "Name");
     var loanReciptPlanViewModel = new LoanReciptPlanViewModel();
     return View(loanReciptPlanViewModel);
 }
 public ActionResult Create(LoanReciptPlanViewModel loanReciptPlanViewModel)
 {
     if (ModelState.IsValid && loanReciptPlanViewModel!=null)
     {
         var loanReciptPlan = GetLoanReciptPlan(loanReciptPlanViewModel);
         _loanReciptPlanService.AddLoanReciptPlan(loanReciptPlan);
         ModelState.AddModelError("Sucess",@"Sucessfully Saved");
         return RedirectToAction("Index");
     }
     return View(loanReciptPlanViewModel);
 }
 private LoanReciptPlan GetLoanReciptPlan(LoanReciptPlanViewModel loanReciptPlanViewModel)
 {
     var loanReciptPlan = new LoanReciptPlan()
             {
                 ProgramID = loanReciptPlanViewModel.ProgramID,
                 CommodityID = loanReciptPlanViewModel.ProgramID,
                 CommoditySourceID = loanReciptPlanViewModel.CommoditySourceID,
                 ShippingInstructionID = _commonService.GetShippingInstruction(loanReciptPlanViewModel.SiNumber),
                 SourceHubID = loanReciptPlanViewModel.SourceHubID,
                 ProjectCode = loanReciptPlanViewModel.ProjectCode,
                 ReferenceNumber = loanReciptPlanViewModel.RefeenceNumber,
                 Quantity = loanReciptPlanViewModel.Quantity,
                 CreatedDate = DateTime.Today
             };
         return loanReciptPlan;
 }
 public void CanCreateNewReciptPlan()
 {
     var loanReciptPlan = new LoanReciptPlanViewModel();
     var result = _reciptPlanForLoanController.Create(loanReciptPlan);
     Assert.IsNotNull(result);
 }
 private LoanReciptPlan GetLoanReciptPlan(LoanReciptPlanViewModel loanReciptPlanViewModel)
 {
     var loanReciptPlan = new LoanReciptPlan()
             {
                 ProgramID = loanReciptPlanViewModel.ProgramID,
                 CommodityID = loanReciptPlanViewModel.ProgramID,
                 CommoditySourceID = 2,//only for loan
                 ShippingInstructionID = _commonService.GetShippingInstruction(loanReciptPlanViewModel.SiNumber),
                 LoanSource = loanReciptPlanViewModel.LoanSource,
                 //HubID = loanReciptPlanViewModel.HubID,
                 ProjectCode = loanReciptPlanViewModel.ProjectCode,
                 ReferenceNumber = loanReciptPlanViewModel.RefeenceNumber,
                 Quantity = loanReciptPlanViewModel.Quantity,
                 CreatedDate = DateTime.Today,
                 StatusID = (int)LocalPurchaseStatus.Draft
             };
         return loanReciptPlan;
 }