예제 #1
0
        public async Task <ActionResult> Create(Reward reward)
        {
            Kid currentKid = await _kidRepository.GetProfileById(reward.KidId);

            if (ModelState.IsValid)
            {
                Reward newReward = new Reward
                {
                    RewardName  = reward.RewardName,
                    Description = reward.Description,
                    Point       = reward.Point,
                    Kid         = currentKid
                };
                _rewardRepository.Add(newReward);

                await _rewardRepository.CommitAsync();

                var toastobj = Helper.getToastObj("Reward was added successfully", "alert-success");
                TempData.Put("toast", toastobj);
                return(RedirectToAction("Details", "Kid", new { reward.KidId }));
            }
            return(View(reward));
        }