protected bool LoginStatus() { try { RegisterViewModel = GetAdminSession(); this.CountryService = new CountryService(Token); this.BusinessCategoryService = new BusinessCategoryService(Token); this.TimezoneService = new TimezoneService(Token); this.MembershipService = new MembershipService(Token); this.BusinessService = new BusinessService(Token); this.BusinessEmployeeService = new BusinessEmployeeService(Token); this.BusinessHourService = new BusinessHourService(Token); this.BusinessHolidayService = new BusinessHolidayService(Token); //Call service; if (RegisterViewModel != null) { return(true); } else { return(false); } } catch { return(false); } }
public async Task <ActionResult> Index(int?page, string search) { var model = this.ResponseHelper.GetResponse <IPagedList <BusinessEmployeeViewModel> >(); var pageNumber = page ?? 1; ViewBag.search = search; ViewBag.BusinessId = RegisterViewModel.Business.Id; ViewBag.ServiceLocationId = RegisterViewModel.Employee.ServiceLocationId; var result = await BusinessEmployeeService.Gets(RegisterViewModel.Business.Id, TableType.BusinessId); if (result.Status) { var data = result.Data; model.Status = result.Status; model.Message = result.Message; if (search == null) { model.Data = data.ToPagedList <BusinessEmployeeViewModel>(pageNumber, 5); } else { model.Data = data.Where(d => d.FirstName.ToLower().Contains(search.ToLower()) || d.LastName.ToLower().Contains(search.ToLower())).ToList().ToPagedList(pageNumber, 5); } } else { model.Status = false; model.Message = result.Message; } return(View(model)); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { var status = LoginStatus(); if (!status) { filterContext.Result = RedirectToAction("Login", "Home", new { area = "Admin" }); } else { this.BusinessEmployeeService = new BusinessEmployeeService(this.Token); } }
// GET: Admin/BusinessAdmin public async Task <ActionResult> Index() { var response = new ResponseViewModel <BusinessEmployeeViewModel>(); var result = await BusinessEmployeeService.Get(RegisterViewModel.Employee.Id); response.Status = result.Status; response.Message = result.Message; if (result.Data != null) { response.Data = result.Data; } return(View(response)); }
public async Task <ActionResult> Login(ServiceDataViewModel <LoginViewModel> model) { var result = new ResponseViewModel <RegisterViewModel>(); try { if (!ModelState.IsValid) { var errMessage = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage)); result.Status = false; result.Message = errMessage; } else { if (BusinessCategoryService != null) { var response = await BusinessEmployeeService.VerifyLoginCredential(model.Data.Email, model.Data.Password); result.Status = response.Status; result.Message = response.Message; result.Data = response.Data; if (response.Status) { var tokenResponse = await BusinessEmployeeService.VerifyAndGetAdminAccessToken(model.Data.Email, model.Data.Password); result.Status = result.Status; result.Message = result.Message; if (tokenResponse.Status) { if (string.IsNullOrEmpty(tokenResponse.Data)) { RedirectToAction("Logout", "Dashboard", new { area = "Admin" }); } SetAdminSession(response.Data, model.Data.IsKeepLoggedIn, tokenResponse.Data); } } } else { result.Status = false; result.Message = "There was a problem. Please try again later."; } } } catch { result.Status = false; result.Message = "There was a problem. Please try again later."; } return(Json(new { status = result.Status, message = result.Message, data = result.Data }, JsonRequestBehavior.AllowGet)); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { var status = LoginStatus(); if (status) { filterContext.Result = RedirectToAction("Index", "Dashboard", new { area = "Admin" }); } else { this.BusinessCategoryService = new BusinessCategoryService(this.Token); this.BusinessEmployeeService = new BusinessEmployeeService(this.Token); } }
public async Task <ActionResult> Administrator() { var result = await BusinessEmployeeService.Get(RegisterViewModel.Employee.Id); if (result != null && result.Status) { return(View(result)); } else { var response = this.ResponseHelper.GetResponse <BusinessEmployeeViewModel>(); return(View(Response)); } }