예제 #1
0
        public ActionResult SearchList(SearchInfringementModel model)
        {
            ViewBag.NoOfRecords                = 0;
            ViewData["NoOfRecords"]            = 0;
            Session["SearchInfringementModel"] = model;

            _logger.Info("Search for infringement");
            var infringements = db.infringements.Include(i => i.parking_location).Include(i => i.make).Include(i => i.infringementtype);
            List <infringement> infringementlist = new List <infringement>();

            if (model.SearchOnRegoNumber == null && model.SearchString == null)
            {
                ModelState.AddModelError("", "Reg No or Infringement value is required.");
                return(View("Search"));
            }
            else if (model.SearchOnRegoNumber != null && model.SearchString != null)
            {
                _logger.Info("Search on rego number");
                infringementlist = infringements
                                   .Where(x => x.Rego.Trim().ToUpper() == model.SearchOnRegoNumber.Trim().ToUpper() & x.Number.Trim().ToUpper() == model.SearchString.Trim().ToUpper() & x.StatusId == 1)
                                   .ToList();
                // return View(infringementlist);
            }
            else if (model.SearchOnRegoNumber != null)
            {
                _logger.Info("Search on rego number");
                infringementlist = infringements
                                   .Where(x => x.Rego.Trim().ToUpper() == model.SearchOnRegoNumber.Trim().ToUpper() && x.StatusId == 1)
                                   .ToList();
                //return View(infringementlist);
            }
            else if (model.SearchString != null)
            {
                _logger.Info("Search on infringement number");
                infringementlist = infringements
                                   .Where(x => x.Number.Trim().ToUpper() == model.SearchString.Trim().ToUpper() && x.StatusId == 1)
                                   .ToList();

                //return View(infringementlist);
            }

            if (infringementlist != null && infringementlist.Count > 0)
            {
                ViewData["NoOfRecords"] = infringementlist.Count;
                ViewBag.NoOfRecords     = infringementlist.Count;
                Session["SearchList"]   = infringementlist;
                return(View(infringementlist));
            }
            else
            {
                ModelState.AddModelError("", "No Records Found with given craiteria. or Payment already done for this Rego Number / Infringement Number.");
                return(View("Search"));
            }
        }
예제 #2
0
        public ActionResult PayNow(List <InfringementWeb.infringement> model, string Email, string InfringementIds)
        {
            List <infringement>     infringementlist = Session["SearchList"] as List <infringement>;
            SearchInfringementModel modeltemp        = Session["SearchInfringementModel"] as SearchInfringementModel;

            if (Email == null || Email.Trim() == "")
            {
                ModelState.AddModelError("", "Please enter the your email and selecct at least one Infringement for payment.");
                return(View("SearchList", infringementlist));
            }
            List <int> IdsToPay = new List <int>();

            string selectedRecs = InfringementIds;

            if (InfringementIds != null && InfringementIds.Length > 0)
            {
                InfringementIds = InfringementIds.Substring(0, InfringementIds.Length - 1);

                string[] ids = InfringementIds.Split(',');
                foreach (string id in ids)
                {
                    IdsToPay.Add(Convert.ToInt16(id));
                }
            }


            if (IdsToPay.Count > 0)
            {
                int[] infringementIds = IdsToPay.ToArray();


                var totalAmount = db.infringements
                                  .Where(x => infringementIds.Contains(x.Id) &&
                                         x.StatusId == 1).Sum(x => x.Amount);
                if (totalAmount > 0)
                {
                    Session["ReceiptEmail"] = Email;

                    return(RedirectToPaymentPage(totalAmount, infringementIds, Email));
                }
                else
                {
                    ModelState.AddModelError("", "Already payment done for these Infringements.");

                    return(View("SearchList", infringementlist));
                }
            }
            else
            {
                return(View("SearchList", infringementlist));
            }
        }