Example #1
0
        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 }));
        }