Пример #1
0
        public async Task <IActionResult> Create([Bind("Name,Description")] Notification notification)
        {
            if (ModelState.IsValid)
            {
                var userName = User.Identity.Name;
                notification.OwnerID = _userManager.GetUserId(User);
                if (!await CheckIfUserAuthorizedForNotification(notification, NotificatinOperations.Create))
                {
                    return(Forbid());
                }

                await _repository.Create(notification);

                await _repository.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(notification));
        }