public ActionResult EditUIModule(long id, AddEditUIModuleViewModel vModel) { ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IUIModule obj = TemplateCache.Get <IUIModule>(id); string message; if (obj == null) { message = "That does not exist"; return(RedirectToAction("UIModules", new { Message = message })); } obj.Name = vModel.Name; obj.BodyHtml = vModel.BodyHtml; obj.Height = vModel.Height; obj.Width = vModel.Width; obj.HelpText = vModel.HelpText; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { LoggingUtility.LogAdminCommandUsage("*WEB* - EditUIModule[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return(RedirectToAction("UIModules", new { Message = message })); }
public ActionResult Edit(long id, AddEditUIModuleViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); IUIModule obj = TemplateCache.Get <IUIModule>(id); if (obj == null) { message = "That does not exist"; return(RedirectToAction("Index", new { Message = message })); } obj.Name = vModel.Name; obj.BodyHtml = vModel.BodyHtml; obj.Height = vModel.Height; obj.Width = vModel.Width; obj.HelpText = vModel.HelpText; obj.SystemDefault = vModel.SystemDefault; if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User))) { IEnumerable <IUIModule> uiModules = TemplateCache.GetAll <IUIModule>().Where(uim => vModel.SystemDefault > 0 && uim.SystemDefault == vModel.SystemDefault && uim != obj); if (uiModules.Count() > 0) { IUIModule revertModule = uiModules.First(); revertModule.SystemDefault = 0; revertModule.Save(authedUser.GameAccount, StaffRank.Admin); } LoggingUtility.LogAdminCommandUsage("*WEB* - EditUIModule[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Edit Successful."; } else { message = "Error; Edit failed."; } return(RedirectToAction("Index", new { Message = message })); }
public ActionResult Add(AddEditUIModuleViewModel vModel) { string message = string.Empty; ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId()); UIModule newObj = new UIModule { Name = vModel.Name, BodyHtml = vModel.BodyHtml, Height = vModel.Height, Width = vModel.Width, HelpText = vModel.HelpText, SystemDefault = vModel.SystemDefault }; IEnumerable <IUIModule> uiModules = TemplateCache.GetAll <IUIModule>().Where(uim => vModel.SystemDefault > 0 && uim.SystemDefault == vModel.SystemDefault); if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null) { message = "Error; Creation failed."; } else { if (uiModules.Count() > 0) { IUIModule revertModule = uiModules.First(); revertModule.SystemDefault = 0; revertModule.Save(authedUser.GameAccount, StaffRank.Admin); } LoggingUtility.LogAdminCommandUsage("*WEB* - AddUIModule[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle); message = "Creation Successful."; } return(RedirectToAction("Index", new { Message = message })); }