Ejemplo n.º 1
0
        public IActionResult NavbarItemsPage([FromServices] INavItemsService navItemsService)
        {
            var navItems = navItemsService.Get();

            string adminUserId = this.GetViewerUserId();

            _logger.LogInformation("Admin: {UserId} viewing Nav items page", adminUserId);

            return(View("NavbarItemsPage", navItems));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> RemoveNavItem([FromServices] INavItemsService navItemsService, [FromForm] NavItemRemove form)
        {
            string adminUserId = this.GetViewerUserId();

            _logger.LogInformation("Admin: {UserId} trying to delete nav item: {NavItemId}",
                                   adminUserId, form.Id.ToString());

            await navItemsService.Remove(form.Id).ConfigureAwait(false);

            _logger.LogInformation("Admin: {UserId} successfully delete nav item: {NavItemId}",
                                   adminUserId, form.Id.ToString());

            return(RedirectToAction("NavbarItemsPage"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> AddNavItem([FromServices] INavItemsService navItemsService, [FromForm] NavItemAdd form)
        {
            if (!ModelState.IsValid)
            {
                TempData["Model"] = "Please provide the Name and Url";
                return(RedirectToAction("NavbarItemsPage"));
            }

            await navItemsService.Add(form.Name, form.Url).CAF();

            string adminUserId = this.GetViewerUserId();

            _logger.LogInformation("Admin: {UserId} added a new nav item", adminUserId);

            return(RedirectToAction("NavbarItemsPage"));
        }