public ActionResult Edit(int ID, Settings item, List <string> Roles) { if (ModelState.IsValid) { List <string> DomainRoles = SF.GetRoleObjectsList().Where(r => r.IsSystem == true).Select(r => r.Title).ToList(); if (Roles != null) { DomainRoles.AddRange(Roles); } item.Roles = SF.RolesListToString(DomainRoles); _db.Entry(item).State = EntityState.Modified; _db.SaveChanges(); //update lang name of pages AbstractPage ap = _db.AbstractPages.FirstOrDefault(r => r.ID == item.DomainPageID); SF.SetLanguageCode(ap, 100, item.LanguageCode); CleanCache.CleanOutputCache(); CleanCache.CleanSettingsCache(); CleanCache.CleanMenuCache(); return(RedirectToAction("Index")); } item.Roles = SF.RolesListToString(Roles); return(View(item)); }
public ActionResult Create(Settings item, List <string> Roles) { if (ModelState.IsValid) { if (_db.SettingsAll.Count(r => r.Domain == item.Domain) > 0) { ModelState.AddModelError("", "Domain + LanguageCode not unic. Please specify different Domain or LanguageCode"); return(View(item)); } string Title = ""; if (string.IsNullOrEmpty(item.Domain)) { Title = (_db.AbstractPages.Max(r => r.ID) + 1).ToString(); } else { Title = item.Domain; } DomainPage dp = new DomainPage(); dp.Title = Title; dp.ParentID = 0; dp.DomainID = 0; dp.SeoUrlName = (_db.AbstractPages.Max(r => r.ID) + 1).ToString(); dp.PermissionsView = SF.RolesListToString(new List <string>() { "Admin", "Anonymous" }); dp.PermissionsEdit = SF.RolesListToString(new List <string>() { "Admin" }); _db.DomainPages.Add(dp); _db.SaveChanges(); List <string> DomainRoles = SF.GetRoleObjectsList().Where(r => r.IsSystem == true).Select(r => r.Title).ToList(); if (Roles != null) { DomainRoles.AddRange(Roles); } item.Roles = SF.RolesListToString(DomainRoles); item.DomainPageID = dp.ID; if (string.IsNullOrEmpty(item.Domain)) { item.Domain = Title; } _db.SettingsAll.Add(item); _db.SaveChanges(); dp.DomainID = item.ID; _db.Entry(dp).State = EntityState.Modified; _db.SaveChanges(); System.IO.Directory.CreateDirectory(Server.MapPath("~/Content/UserFiles/" + item.ID)); System.IO.Directory.CreateDirectory(Server.MapPath("~/App_Data/cache/images/" + item.ID)); CleanCache.CleanOutputCache(); CleanCache.CleanSettingsAllCache(); return(RedirectToAction("Index")); } return(View(item)); }