public ActionResult CreateNew(CreativeDetailsViewModel creativeDetailsViewModel) { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/2012dev4good"); System.Configuration.ConnectionStringSettings connString = null; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { connString = rootWebConfig.ConnectionStrings.ConnectionStrings["CMEntities"]; if (connString != null) Console.WriteLine("CMEntities connection string = \"{0}\"", connString.ConnectionString); else Console.WriteLine("No CMEntities connection string"); } CreativeDetail cd = new CreativeDetail(); cd.UserId = 1; cd.Title = creativeDetailsViewModel.Title; cd.Body = creativeDetailsViewModel.Body; cd.Footer = "Footer"; cd.AddedDate = DateTime.UtcNow; cd.UpdateDate = DateTime.UtcNow; CMEntities cm = new CMEntities(connString.ConnectionString); cm.AddToCreativeDetails(cd); cm.SaveChanges(); //send email to moderator SendModeratorEmail(cd); return RedirectToAction("Index", "Home"); }
public ActionResult About() { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/2012dev4good"); System.Configuration.ConnectionStringSettings connString = null; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { connString = rootWebConfig.ConnectionStrings.ConnectionStrings["CMEntities"]; if (connString != null) Console.WriteLine("CMEntities connection string = \"{0}\"", connString.ConnectionString); else Console.WriteLine("No CMEntities connection string"); } CreativeDetail cd = new CreativeDetail(); cd.UserId = 1; cd.Title = "title"; cd.Body = "Body"; cd.Footer = "Footer"; CMEntities cm = new CMEntities(connString.ConnectionString); cm.AddToCreativeDetails(cd); cm.SaveChanges(); return View(); }