Esempio n. 1
0
        public ActionResult Create(Reward reward)
        {
            Campaign campaign = _db.Campaigns.Find(reward.Goal.Campaign.CampaignID);
            if (campaign == null) { return HttpNotFound(); }
            if (campaign.Creator.UserId != (Guid)Membership.GetUser().ProviderUserKey) { return HttpNotFound(); }
            if (ModelState.IsValid)
            {
                _db.Rewards.Add(reward);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.RewardTypeID = new SelectList(_db.RewardTypes, "RewardTypeID", "Name", reward.RewardTypeID);
            ViewBag.GoalID = new SelectList(_db.Goals.Where(g => g.CampaignID == reward.Goal.CampaignID), "GoalID", "Name", reward.GoalID);
            return View(reward);
        }
		private void detach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.RewardType = null;
		}
		private void attach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.RewardType = this;
		}
 partial void DeleteReward(Reward instance);
 partial void UpdateReward(Reward instance);
 partial void InsertReward(Reward instance);
		private void detach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.UserProfile = null;
		}