public async Task <IViewComponentResult> InvokeAsync()
        {
            var vm = new ToolbarVM
            {
                //TODO: get menu_id from url
                MenuId = UrlHelper.GetMenuFromUrl(HttpContext.Request)
            };

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                var menuAuthorization = await _uow.Repository <MenuAuthorization>()
                                        .Query(x => x.MenuId == vm.MenuId)
                                        .FirstOrDefaultAsync();

                if (menuAuthorization != null)
                {
                    vm.CanCreate = menuAuthorization.CanCreate;
                    vm.CanDelete = menuAuthorization.CanDelete;
                    vm.CanEdit   = menuAuthorization.CanEdit;
                    vm.CanExport = menuAuthorization.CanRead;
                    vm.CanRead   = menuAuthorization.CanRead;
                    vm.CanSave   = menuAuthorization.CanCreate;
                }
            }

            return(View(vm));
        }
        public async Task <ActionResult <ProfileVM> > Profile(Guid?id = null, string sortOrder = "newest", int pageNumber = 1, Guid?categoryId = null)
        {
            ViewData["CurrentSort"] = sortOrder;
            ViewData["PageNumber"]  = pageNumber;
            ViewData["Category"]    = categoryId;

            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            if (id == null || id == Guid.Empty)
            {
                id = user.Id;
            }

            var vm = await _service.GetProfileData(id.Value, user.Id, sortOrder, pageNumber, 5, categoryId);

            if (!vm.IsSuccessful)
            {
                return(RedirectToAction("Index", "Home"));
            }

            ToolbarVM toolbarVM = new ToolbarVM();

            toolbarVM.ControllerName = "User";
            toolbarVM.ActionName     = "Profile";
            toolbarVM.ShowSearch     = false;
            toolbarVM.Categories     = _categoryService.GetSelectList();

            (vm.Rec as ProfileVM).ToolbarData = toolbarVM;

            return(View(vm.Rec));
        }
        public async Task <ActionResult <UserPaggingListVM> > Index(string searchString = "", int pageNumber = 1)
        {
            ViewData["CurrentFilter"] = searchString;
            ViewData["PageNumber"]    = pageNumber;

            var result = _service.GetList(searchString, pageNumber, 5);

            result.Pagging.ActionName     = "Index";
            result.Pagging.ControllerName = "User";

            ToolbarVM toolbarVM = new ToolbarVM();

            toolbarVM.ControllerName     = "User";
            toolbarVM.ActionName         = "Index";
            toolbarVM.ShowSearch         = true;
            toolbarVM.Categories         = null;
            toolbarVM.ShowCategories     = false;
            toolbarVM.ShowSortingOptions = false;

            result.ToolbarData = toolbarVM;

            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            result.CurrentUserId = user.Id;

            return(View(result));
        }
        public ActionResult <IAsyncEnumerable <SuggestionPaggingListVM> > Index(string sortOrder = "newest", string searchString = "", int pageNumber = 1, Guid?categoryId = null)
        {
            ViewData["CurrentSort"]   = sortOrder;
            ViewData["CurrentFilter"] = searchString;
            ViewData["PageNumber"]    = pageNumber;
            ViewData["Category"]      = categoryId;

            var suggestions = _suggestionService.GetList(false, searchString, sortOrder, pageNumber, 5, categoryId);

            suggestions.Pagging.ActionName     = "Index";
            suggestions.Pagging.ControllerName = "Home";

            ToolbarVM toolbarVM = new ToolbarVM();

            toolbarVM.ControllerName = "Home";
            toolbarVM.ActionName     = "Index";
            toolbarVM.ShowSearch     = true;
            toolbarVM.Categories     = _categoryService.GetSelectList();

            suggestions.ToolbarData = toolbarVM;

            return(View(suggestions));
        }
 public MainPage()
 {
     InitializeComponent();
     Toolbar = new ToolbarVM(this);
 }