public ActionResult Create(CreateCampaignViewModel campaignModel) { if (ModelState.IsValid) { Campaign campaign = campaignModel.Campaign; campaign.Revision = 1; campaign.UserGroup = context.UserGroups.ToList()[0]; campaign.Publisher = context.Users.ToList()[0]; campaign.Branch = context.Branches.ToList()[0]; campaign.Active = true; try { context.Campaigns.Add(campaign); context.SaveChanges(); return RedirectToAction("CampaignList"); } catch (Exception) { return View(); } } else { campaignModel.BranchesDropDown = PopulateBranchesDropDown(1); campaignModel.ProximityDropDown = PopulateBeaconsDropDown(1); return View(campaignModel); } }
public ActionResult Create(int? id) { int userID = 1; CreateCampaignViewModel newCampaign = new CreateCampaignViewModel(); newCampaign.BranchesDropDown = PopulateBranchesDropDown(userID); if (id != null) { newCampaign.Campaign = context.Campaigns.Find(id); newCampaign.Campaign.Title = newCampaign.Campaign.Title + " copy"; } return View(newCampaign); }