protected void Application_Start() { if (!Roles.RoleExists("CanPostNews")) Roles.CreateRole("CanPostNews"); if (Membership.GetUser("admin") == null) { Membership.CreateUser("admin", "*****@*****.**", "*****@*****.**"); Roles.AddUserToRole("admin", "CanPostNews"); } var db = new pmiEntities(); var si = db.SiteInfoes.Find(1); if (si == null) { var defaultSiteInfo = new SiteInfo(); defaultSiteInfo.theme = "Default"; defaultSiteInfo.footer = "footer"; db.SiteInfoes.Add(defaultSiteInfo); db.SaveChanges(); } AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); RegisterViewEngine(ViewEngines.Engines); }
public ActionResult Index(SiteInfo siteinfo) { if (ModelState.IsValid) { try { db.Entry(siteinfo).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } catch (DbEntityValidationException ex) { var errors = ex.EntityValidationErrors.First().ValidationErrors.First(); this.ModelState.AddModelError(errors.PropertyName, errors.ErrorMessage); } } ViewBag.theme = getThemeList(siteinfo.theme); return View(siteinfo); }