public ActionResult Save(Reward reward)
        {
            if (reward != null)
            {
                if (string.IsNullOrEmpty(reward.Title))
                {
                    return(new HttpStatusCodeResult(404, "Title can't be empty :("));
                }
                if (reward.Description == null)
                {
                    reward.Description = "";
                }

                if (rewards.GetRewards().Any(c => c.ID == reward.ID))
                {
                    rewards.UpdateReward(reward);
                }
                else
                {
                    rewards.AddReward(reward);
                }
            }

            return(RedirectToAction("Index", "User"));
        }
Example #2
0
        private void AddReward(object sender, EventArgs e)
        {
            Reward reward;

            RewardForm uf = new RewardForm();

            if (uf.ShowDialog() == DialogResult.OK)
            {
                reward = new Reward
                {
                    Title       = uf.Title,
                    Description = uf.Description
                };

                Rewards.AddReward(reward);
            }

            DisplayRewards();
        }