public ActionResult SearchByNumber(SearchModel2 model, int?grid_page) { ViewData["VoucherList"] = Enumerable.Empty <fileInfo>(); ViewData["CountryList"] = HttpContext.Application.Get <List <CountryDetail> >("CountryList", Helper.CreateCountryDropDownLoadFunction()).CreateSelectList( (c) => string.Format("{0} - {1}", c.Country, c.Iso2), (c) => c.Number.ToString()); if (model.Country == 0) { throw new ArgumentException("model.Country"); } model.Validate(this.ModelState); if (this.ModelState.IsValid) { Session.Set("SearchModel2", model); var sdc = new ScanServiceAccess(); var infos = sdc.SelectVouchersByNumber(model.Country, model.Voucher); ViewData["VoucherList"] = infos.ToList(); } return(View(model)); }
public static Lazy <Dictionary <int, CurrentUser> > GetUserTableLazy() { var lazy = new Lazy <Dictionary <int, CurrentUser> >(new Func <Dictionary <int, CurrentUser> >(() => { var sdc2 = new ScanServiceAccess(); var uslist = sdc2.RetrieveUsers(); return(uslist); }), true); return(lazy); }
public static Func <int, int, List <Retailer> > CreateRetailerDropDownLoadFunction() { var funct = new Func <int, int, List <Retailer> >((countryId, headOfficeId) => { var sac = new ScanServiceAccess(); var results = sac.RetrieveRetailerList(new AuthenticationHeader(), countryId, headOfficeId); var results2 = results.ToList(); results2.Sort((c1, c2) => string.Compare(c1.Name, c2.Name)); return(results2); }); return(funct); }
public ActionResult Search(SearchModel model) { ViewData["VoucherList"] = Enumerable.Empty <VoucherInfo>(); ViewData["CountryList"] = HttpContext.Application.Get <List <CountryDetail> >("CountryList", Helper.CreateCountryDropDownLoadFunction()).CreateSelectList( (c) => string.Format("{0} - {1}", c.Country, c.Iso2), (c) => c.Number.ToString()); if (model.Country == 0) { throw new ArgumentException("model.Country"); } ViewData["HeadOfficeList"] = HttpContext.Session.Get <int, List <HeadOffice> >("HeadOfficeList" + model.Country, Helper.CreateHeadOfficeDropDownLoadFunction(), model.Country).CreateSelectList((h) => string.Format("{0} - {1}", h.Name, h.Id), (h) => h.Id.ToString()); if (model.HeadOffice == 0) { throw new ArgumentException("model.HeadOffice"); } ViewData["RetailerList"] = HttpContext.Session.Get <int, int, List <Retailer> >("RetailerList" + model.Country + ";" + model.HeadOffice, Helper.CreateRetailerDropDownLoadFunction(), model.Country, model.HeadOffice).CreateSelectList((r) => string.Format("{0} - {1}", r.Name, r.Id), (r) => r.Id.ToString()); model.Validate(this.ModelState); if (this.ModelState.IsValid) { this.Session.Set(MerchantSiteStrings.SearchModel, model); var sdc = new ScanServiceAccess(); var list = sdc.SelectVouchersByRetailer(model.Country, model.Retailer); var lazy = Helper.GetUserTableLazy(); ViewBag.UserDictionary = DataTables.Default.Get <Dictionary <int, CurrentUser> >(MerchantSiteStrings.USERS, lazy); ViewData["VoucherList"] = list; } return(View(model)); }
public ActionResult Login(LoginModel model, string returnUrl) { if (model.Country == 0) { ModelState.AddModelError("Country", "Country is mandatory"); } HttpContext.Application.Get <List <CountryDetail> >("CountryList", Helper.CreateCountryDropDownLoadFunction()).CreateSelectList( (c) => string.Format("{0} - {1}", c.Country, c.Iso2), (c) => c.Number.ToString()); if (ModelState.IsValid) { var acc = new ScanServiceAccess(); var user = acc.TryLogin(model.Country, model.UserName, model.Password); if (user.IsValid) { new FormsAuthenticationService().SignIn(model.UserName, model.RememberMe, string.Concat(user.UserID, '|', user.CountryID)); return(RedirectToLocal(returnUrl)); } } ModelState.AddModelError("", "The user name or password provided is incorrect."); return(Login(returnUrl)); }