예제 #1
0
        public ActionResult Create(Campaign campaign)
        {
            var currentUserId = (Guid)Membership.GetUser().ProviderUserKey;
            campaign.DateCreated = DateTime.Now;
            campaign.UserId = currentUserId;
            campaign.Appoved = true; //default false, approve by admin
            campaign.Active = true; //default false , activate after submit
            campaign.Email = _db.Users.SingleOrDefault(u => u.UserId == currentUserId).Membership.Email;
            campaign.Location = _db.Users.SingleOrDefault(u => u.UserId == currentUserId).Profile.Location;
            campaign.EndDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                _db.Campaigns.Add(campaign);
                _db.SaveChanges();
                return RedirectToAction("Edit", "Campaigns", new { id = campaign.CampaignID });

            }

            ViewBag.AccountId = new SelectList(_db.Accounts, "AccountID", "AccountID", campaign.AccountId);
            ViewBag.CampaignTypeId = new SelectList(_db.CampaignTypes, "CampaignTypeID", "Name", campaign.CampaignTypeId);
            ViewBag.GenreID = new SelectList(_db.Genres, "ID", "Name", campaign.GenreID);
            ViewBag.UserId = new SelectList(_db.Users, "UserId", "UserName", campaign.UserId);
            return View(campaign);
        }
예제 #2
0
		private void detach_Campaigns(Campaign entity)
		{
			this.SendPropertyChanging();
			entity.Account = null;
		}
예제 #3
0
		private void attach_Campaigns(Campaign entity)
		{
			this.SendPropertyChanging();
			entity.Account = this;
		}
예제 #4
0
 partial void DeleteCampaign(Campaign instance);
예제 #5
0
 partial void UpdateCampaign(Campaign instance);
예제 #6
0
 partial void InsertCampaign(Campaign instance);
예제 #7
0
		private void detach_Campaigns2(Campaign entity)
		{
			this.SendPropertyChanging();
			entity.File2 = null;
		}
예제 #8
0
		private void attach_Campaigns2(Campaign entity)
		{
			this.SendPropertyChanging();
			entity.File2 = this;
		}
예제 #9
0
		private void detach_Campaigns(Campaign entity)
		{
			this.SendPropertyChanging();
			entity.UserProfile = null;
		}
예제 #10
0
        public ActionResult Edit(Campaign campaign)
        {
            if (campaign == null)return HttpNotFound();

            var currentUserId = (Guid)Membership.GetUser().ProviderUserKey;
            var existingCampaign = _db.Campaigns.Find(campaign.CampaignID);
            if (existingCampaign.UserId != currentUserId) { return HttpNotFound(); }

            if (ModelState.IsValid)
            {
                existingCampaign.Location = campaign.Location;
                existingCampaign.Name = campaign.Name;
                existingCampaign.Location = campaign.Location;
                existingCampaign.Intro = campaign.Intro;
                existingCampaign.Email = campaign.Email;
                existingCampaign.EndDate = campaign.EndDate;
                existingCampaign.CampaignTypeId = campaign.CampaignTypeId;
                existingCampaign.GenreID = campaign.GenreID;

                _db.Entry(existingCampaign).State = EntityState.Modified;
                _db.SaveChanges();
                return RedirectToAction("Details", "Campaigns", new { id = existingCampaign.CampaignID });

            }
            ViewBag.AccountId = new SelectList(_db.Accounts, "AccountID", "AccountID", campaign.AccountId);
            ViewBag.CampaignTypeId = new SelectList(_db.CampaignTypes, "CampaignTypeID", "Name", campaign.CampaignTypeId);
            ViewBag.GenreID = new SelectList(_db.Genres, "ID", "Name", campaign.GenreID);
            ViewBag.UserId = new SelectList(_db.Users, "UserId", "UserName", campaign.UserId);
            return View(campaign);
        }