예제 #1
0
        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);
            }
        }
예제 #2
0
        public async Task <ActionResult> Location(long?id, int?page, string search)
        {
            if (id.HasValue)
            {
                var model      = this.ResponseHelper.GetResponse <IPagedList <BusinessOfferServiceLocationViewModel> >();
                var pageNumber = page ?? 1;
                ViewBag.search = search;

                ViewBag.Id                = id.Value;
                ViewBag.BusinessId        = RegisterViewModel.Business.Id;
                ViewBag.ServiceLocationId = RegisterViewModel.Employee.ServiceLocationId;
                ViewBag.EmployeeId        = RegisterViewModel.Employee.Id;

                var result = await BusinessOfferServiceLocationService.Gets(id.Value);

                if (result.Status)
                {
                    var data = result.Data;
                    model.Status  = result.Status;
                    model.Message = result.Message;
                    if (data != null)
                    {
                        if (search == null)
                        {
                            model.Data = data.ToPagedList <BusinessOfferServiceLocationViewModel>(pageNumber, 5);
                        }
                        else
                        {
                            model.Data = data.Where(d => d.ServiceLocationViewModel.Name.ToLower().Contains(search.ToLower())).ToList().ToPagedList(pageNumber, 5);
                        }
                    }
                }
                else
                {
                    model.Status  = false;
                    model.Message = result.Message;
                    model.Data    = null;
                }
                return(View(model));
            }
            return(RedirectToAction("index"));
        }