Пример #1
0
        public ActionResult Detail(int id)
        {
            var loanReciptPlan = _loanReciptPlanService.FindById(id);



            if (loanReciptPlan == null)
            {
                return(HttpNotFound());
            }

            var loan = new LoanReciptPlanViewModel
            {
                RefeenceNumber      = loanReciptPlan.ReferenceNumber,
                SiNumber            = loanReciptPlan.ShippingInstruction.Value,
                ProjectCode         = loanReciptPlan.ProjectCode,
                Quantity            = loanReciptPlan.Quantity,
                ProgramName         = loanReciptPlan.Program.Name,
                CommodityName       = loanReciptPlan.Commodity.Name,
                CommoditySourceName = loanReciptPlan.CommoditySource.Name,
                LoanReciptPlanID    = loanReciptPlan.LoanReciptPlanID
            };

            var loanSource     = loanReciptPlan.LoanSource;
            var intLoanSource  = Convert.ToInt32(loanSource);
            var firstOrDefault =
                _commonService.GetDonors(d => d.DonorID == intLoanSource).FirstOrDefault();

            if (firstOrDefault != null)
            {
                loan.Donor = firstOrDefault.Name;
            }
            loan.StatusID = loanReciptPlan.StatusID;
            return(View(loan));
        }
        public void CanCreateNewReciptPlan()
        {
            var loanReciptPlan = new LoanReciptPlanViewModel();
            var result         = _reciptPlanForLoanController.Create(loanReciptPlan);

            Assert.IsNotNull(result);
        }
Пример #3
0
 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));
 }
Пример #4
0
        public ActionResult Create()
        {
            ViewBag.ProgramID         = new SelectList(_commonService.GetPrograms(), "ProgramID", "Name");
            ViewBag.CommodityID       = new SelectList(_commonService.GetCommodities(), "CommodityID", "Name");
            ViewBag.SourceHubID       = new SelectList(_commonService.GetAllHubs(), "HubID", "Name");
            ViewBag.CommodityTypeID   = new SelectList(_commonService.GetCommodityTypes(), "CommodityTypeID", "Name");
            ViewBag.CommoditySourceID = new SelectList(_commonService.GetCommoditySource(), "CommoditySourceID", "Name", 2);
            //ViewBag.HubID = new SelectList(_commonService.GetAllHubs(), "HubID", "Name");
            var loanReciptPlanViewModel = new LoanReciptPlanViewModel();

            loanReciptPlanViewModel.CommoditySourceName = _commonService.GetCommditySourceName(2);//commodity source for Loan
            return(View(loanReciptPlanViewModel));
        }
Пример #5
0
        private LoanReciptPlan GetLoanReciptPlan(LoanReciptPlanViewModel loanReciptPlanViewModel)
        {
            var loanReciptPlan = new LoanReciptPlan()
            {
                ProgramID             = loanReciptPlanViewModel.ProgramID,
                CommodityID           = loanReciptPlanViewModel.CommodityID,
                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);
        }
Пример #6
0
        private IEnumerable <LoanReciptPlanViewModel> BindToViewModel(IEnumerable <LoanReciptPlan> loanReciptPlans)
        {
            var datePref    = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference;
            var list        = new List <LoanReciptPlanViewModel>();
            var reciptPlans = loanReciptPlans as List <LoanReciptPlan> ?? loanReciptPlans.ToList();

            foreach (var loanReciptPlan in reciptPlans)
            {
                var loanSource     = loanReciptPlan.LoanSource;
                var intLoanSource  = Convert.ToInt32(loanSource);
                var firstOrDefault =
                    _commonService.GetDonors(d => d.DonorID == intLoanSource).FirstOrDefault();
                var loan = new LoanReciptPlanViewModel
                {
                    LoanReciptPlanID    = loanReciptPlan.LoanReciptPlanID,
                    ProgramName         = loanReciptPlan.Program.Name,
                    CommodityName       = loanReciptPlan.Commodity.Name,
                    CommoditySourceName = loanReciptPlan.CommoditySource.Name,
                    LoanSource          = intLoanSource
                };

                if (firstOrDefault != null)
                {
                    loan.Donor = firstOrDefault.Name;
                }
                //SourceHubName = loanReciptPlan.Hub.Name,
                loan.RefeenceNumber = loanReciptPlan.ReferenceNumber;
                loan.SiNumber       = loanReciptPlan.ShippingInstruction.Value;
                loan.ProjectCode    = loanReciptPlan.ProjectCode;
                loan.Quantity       = loanReciptPlan.Quantity;
                loan.StatusID       = loanReciptPlan.StatusID;
                loan.CreatedDate    = loanReciptPlan.CreatedDate.ToCTSPreferedDateFormat(datePref);
                loan.Status         = _commonService.GetStatusName(WORKFLOW.LocalPUrchase, loanReciptPlan.StatusID);
                loan.IsFalseGRN     = loanReciptPlan.IsFalseGRN;

                list.Add(loan);
            }

            return(list);
            //return (from loanReciptPlan in reciptPlans
            //        let loanSource = loanReciptPlan.LoanSource
            //        where loanSource != null
            //        let intLoanSource = Convert.ToInt32(loanSource)
            //        let firstOrDefault = _commonService.GetDonors(d=>d.DonorID == Convert.ToInt32(loanSource)).FirstOrDefault()
            //        where firstOrDefault != null
            //        select new LoanReciptPlanViewModel
            //            {
            //                LoanReciptPlanID = loanReciptPlan.LoanReciptPlanID,
            //                ProgramName = loanReciptPlan.Program.Name,
            //                CommodityName = loanReciptPlan.Commodity.Name,
            //                CommoditySourceName = loanReciptPlan.CommoditySource.Name,
            //                LoanSource = intLoanSource,
            //                Donor = firstOrDefault.Name,
            //                //SourceHubName = loanReciptPlan.Hub.Name,
            //                RefeenceNumber = loanReciptPlan.ReferenceNumber,
            //                SiNumber = loanReciptPlan.ShippingInstruction.Value,
            //                ProjectCode = loanReciptPlan.ProjectCode,
            //                Quantity = loanReciptPlan.Quantity,
            //                StatusID = loanReciptPlan.StatusID,
            //                CreatedDate = loanReciptPlan.CreatedDate.ToCTSPreferedDateFormat(datePref),
            //                Status = _commonService.GetStatusName(WORKFLOW.LocalPUrchase, loanReciptPlan.StatusID),
            //                IsFalseGRN = loanReciptPlan.IsFalseGRN
            //            });
        }