Esempio n. 1
0
        public async Task <IActionResult> Archive(int id)
        {
            //Cannot be null as Role requires user being logged in
            ApplicationUser user = await _userService.GetUserAsync(User);

            if (!(await _routeService.IsRouteCreatedByUser(id, user.Id) ||
                  await _userService.IsInRoleAsync(user, RoleHandler.Admin)))
            {
                HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;

                return(Content("You don't have access to this action. 403 Forbidden"));
            }

            _routeService.ArchiveRoute(id);

            return(RedirectToAction("List")); //TODO: return to earlier search
        }