private IActionResult Decision(int id, bool IsApproved, string comments)
        {
            var reward = _rewardService.GetReward(id);

            if (reward == null)
            {
                return(NotFound());
            }

            if (reward.Review?.IsApproved != null)
            {
                return(View("Status", new StatusViewModel
                {
                    Message = "This reward has already been reviewed."
                }));
            }

            reward.Review = new Review
            {
                IsApproved = IsApproved,
                Comments   = comments,
                Timestamp  = DateTime.Now,
                ReviewerId = User.FindFirstValue(ClaimTypes.NameIdentifier)
            };
            _rewardService.SaveChanges();

            _logger.LogInformation("{user} reviewed reward {reward} with approval={decision}",
                                   User.Identity.Name, reward.Id, IsApproved);

            var msg = _emailSender.CreateRewardReviewedMessage(reward);

            if (msg != null)
            {
                _ = _emailSender.SendAsync(msg);
            }

            return(RedirectToAction("Index"));
        }
        public IActionResult Create(RewardInputModel input, bool saveDraft = false)
        {
            if (!ModelState.IsValid)
            {
                return(View(input));
            }

            var reward = _mapper.Map <Reward>(input);

            reward.CreatorId = User.FindFirstValue(ClaimTypes.NameIdentifier);
            _rewardService.AddReward(reward);
            _rewardService.SaveChanges();

            _logger.LogInformation("{user} created reward {reward}", User.Identity.Name, reward.Id);

            return(saveDraft ? RedirectToAction("Index") : RedirectToAction("Attachments", new { id = reward.Id }));
        }