public async Task <ActionResult> Index(int?page, string search) { var model = this.ResponseHelper.GetResponse <IPagedList <BusinessOfferViewModel> >(); var pageNumber = page ?? 1; ViewBag.search = search; ViewBag.BusinessId = RegisterViewModel.Business.Id; ViewBag.ServiceLocationId = RegisterViewModel.Employee.ServiceLocationId; ViewBag.EmployeeId = RegisterViewModel.Employee.Id; var result = await BusinessOfferService.Gets(RegisterViewModel.Employee.Id, TableType.EmployeeId); if (result.Status) { var data = result.Data; model.Status = result.Status; model.Message = result.Message; if (search == null) { model.Data = data.ToPagedList <BusinessOfferViewModel>(pageNumber, 5); } else { model.Data = data.Where(d => d.Name.ToLower().Contains(search.ToLower())).ToList().ToPagedList(pageNumber, 5); } } else { model.Status = false; model.Message = result.Message; model.Data = null; } return(View(model)); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { var status = LoginStatus(); if (!status) { filterContext.Result = RedirectToAction("Login", "Home", new { area = "Admin" }); } else { this.BusinessOfferService = new BusinessOfferService(this.Token); this.ServiceLocationService = new ServiceLocationService(this.Token); this.BusinessOfferServiceLocationService = new BusinessOfferServiceLocationService(this.Token); } }