Exemplo n.º 1
0
        public void CreateReward(string userID, string name, string description, int cost)
        {
            var reward = new Reward()
            {
                UserID      = userID,
                Cost        = cost,
                Description = description,
                Name        = name
            };

            rewardRepository.Add(reward);
            rewardRepository.SaveChanges();
        }
Exemplo n.º 2
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));
        }