Ejemplo n.º 1
0
        public bool CreateReward(RewardCreateRAO model)
        {
            var groupService = new GroupService(_userId);

            var reward = new RewardEntity
            {
                RewardName  = model.RewardName,
                Description = model.RewardDescription,
                Cost        = model.RewardCost,
                GroupId     = model.GroupId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Rewards.Add(reward);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(RewardCreateDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            var svc = CreateRewardService();
            var rao = new RewardCreateRAO
            {
                GroupId           = dto.GroupId,
                RewardCost        = dto.RewardCost,
                RewardDescription = dto.RewardDescription,
                RewardName        = dto.RewardName
            };

            if (svc.CreateReward(rao))
            {
                return(RedirectToAction("Index", "Reward", new { id = dto.GroupId }));
            }

            return(View(dto));
        }