public static RoleViewModel FromISiteRole(ISiteRole siteRole) { RoleViewModel model = new RoleViewModel(); model.Id = siteRole.Id; model.NormalizedRoleName = siteRole.NormalizedRoleName; model.RoleName = siteRole.RoleName; model.SiteId = siteRole.SiteId; return model; }
public static RoleViewModel FromISiteRole(ISiteRole siteRole) { RoleViewModel model = new RoleViewModel(); model.RoleGuid = siteRole.RoleGuid; model.RoleId = siteRole.RoleId; model.RoleName = siteRole.RoleName; model.DisplayName = siteRole.DisplayName; model.SiteGuid = siteRole.SiteGuid; model.SiteId = siteRole.SiteId; return model; }
public async Task<IActionResult> RoleEdit( Guid? siteId, Guid? roleId) { var selectedSite = await siteManager.GetSiteForDataOperations(siteId); // only server admin site can edit other sites settings if (selectedSite.Id != siteManager.CurrentSite.Id) { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - New Role"], selectedSite.SiteName); } else { ViewData["Title"] = sr["New Role"]; } var model = new RoleViewModel(); model.SiteId = selectedSite.Id; if (roleId.HasValue) { var role = await RoleManager.FindByIdAsync(roleId.Value.ToString()); if ((role != null) && (role.SiteId == selectedSite.Id)) { model = RoleViewModel.FromISiteRole(role); ViewData["Title"] = sr["Edit Role"]; } } return View(model); }
public async Task<IActionResult> RoleEdit(RoleViewModel model, int returnPageNumber = 1) { var selectedSite = await siteManager.GetSiteForDataOperations(model.SiteId); // only server admin site can edit other sites settings if (selectedSite.Id != siteManager.CurrentSite.Id) { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, sr["{0} - Edit Role"], selectedSite.SiteName); } else { ViewData["Title"] = sr["Edit Role"]; } if (!ModelState.IsValid) { return View(model); } string successFormat; var role = SiteRole.FromISiteRole(model); if (model.Id == Guid.Empty) { var exists = await RoleManager.RoleExistsAsync(model.RoleName); if(exists) { ModelState.AddModelError("roleerror", sr["The role name is already in use."]); return View(model); } role.SiteId = selectedSite.Id; successFormat = sr["The role <b>{0}</b> was successfully created."]; await RoleManager.CreateAsync(role); } else { successFormat = sr["The role <b>{0}</b> was successfully updated."]; await RoleManager.UpdateAsync(role); } this.AlertSuccess(string.Format(successFormat, role.RoleName), true); return RedirectToAction("Index", new { siteId = selectedSite.Id, pageNumber = returnPageNumber }); }
public async Task<IActionResult> RoleEdit(RoleViewModel model, int returnPageNumber = 1) { ISiteSettings selectedSite; // only server admin site can edit other sites settings if ((model.SiteGuid != Guid.Empty) && (model.SiteGuid != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite)) { selectedSite = await siteManager.Fetch(model.SiteGuid); ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - Edit Role", selectedSite.SiteName); } else { selectedSite = siteManager.CurrentSite; ViewBag.Title = "Edit Role"; } if (!ModelState.IsValid) { return View(model); } string successFormat; if ((model.SiteId == -1) || (model.SiteGuid == Guid.Empty)) { model.SiteId = selectedSite.SiteId; model.SiteGuid = selectedSite.SiteGuid; successFormat = "The role <b>{0}</b> was successfully created."; } else { successFormat = "The role <b>{0}</b> was successfully updated."; } bool result = await RoleManager.SaveRole(model); if (result) { this.AlertSuccess(string.Format(successFormat, model.DisplayName), true); } return RedirectToAction("Index", new { siteGuid = selectedSite.SiteGuid, pageNumber = returnPageNumber }); }
//[MvcSiteMapNode(Title = "New Role", ParentKey = "Roles", Key = "RoleEdit")] public async Task<IActionResult> RoleEdit( Guid? siteGuid, int? roleId) { ISiteSettings selectedSite; // only server admin site can edit other sites settings if ((siteGuid.HasValue) && (siteGuid.Value != Guid.Empty) && (siteGuid.Value != siteManager.CurrentSite.SiteGuid) && (siteManager.CurrentSite.IsServerAdminSite)) { selectedSite = await siteManager.Fetch(siteGuid.Value); ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, "{0} - New Role", selectedSite.SiteName); } else { selectedSite = siteManager.CurrentSite; ViewBag.Title = "New Role"; } RoleViewModel model = new RoleViewModel(); model.SiteGuid = selectedSite.SiteGuid; model.SiteId = selectedSite.SiteId; model.Heading = "New Role"; if (roleId.HasValue) { ISiteRole role = await RoleManager.FetchRole(roleId.Value); if ((role != null) && (role.SiteId == selectedSite.SiteId)) { model = RoleViewModel.FromISiteRole(role); ViewBag.Title = "Edit Role"; model.Heading = "Edit Role"; // below we are just manipiulating the bread crumbs //var node = SiteMaps.Current.FindSiteMapNodeFromKey("RoleEdit"); //var node = SiteMaps.Current.FindSiteMapNodeFromKey("RoleEdit"); //if (node != null) //{ // node.Title = "Edit Role"; //} } } return View(model); }
public RoleMemberListViewModel() { Role = new RoleViewModel(); Members = new List <IUserInfo>(); Paging = new PaginationSettings(); }
public RoleMemberListViewModel() { Role = new RoleViewModel(); Members = new List<IUserInfo>(); Paging = new PaginationSettings(); }
public RoleMemberListViewModel() { Role = new RoleViewModel(); Members = new PagedResult <IUserInfo>(); }