public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { var bllRole = RoleService.GetAll().FirstOrDefault(r => r.Name == roleName); if (bllRole == null) { return(false); } var id = bllRole.Id; RoleService.Delete(id); return(true); }
private void LoadRoles(string roleName) { if (string.IsNullOrEmpty(roleName)) { RolesList = RolesService.GetAll(); } }
public MembershipUser CreateUser(string email, string firstName, string lastName, string password) { if (GetUser(email, false) != null) { return(null); } var user = new BllUser { Email = email, FirstName = firstName, LastName = lastName, Password = Crypto.HashPassword(password) }; var role = RoleService.GetAll()?.FirstOrDefault(r => r.Name == "User"); if (role != null) { user.RoleId = role.Id; } UserService.Create(user); return(GetUser(email, false)); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } object ob = Session["LoginOk"]; if (ob == null) { Response.Write("<script>alert('账号过期,请重新登入');location.href='../Login.aspx'</script>"); } #region 绑定下拉列表 var data = rolesSvc.GetAll(); this.ddlRolesId.DataSource = data; this.ddlRolesId.DataTextField = "Roles_Title"; this.ddlRolesId.DataValueField = "Roles_Id"; this.ddlRolesId.DataBind(); #endregion Bind(); }
public void RolesBind() { var data = roleSvc.GetAll(); this.ddlRoles.DataSource = data; this.ddlRoles.DataValueField = "Roles_Id"; this.ddlRoles.DataTextField = "Roles_Title"; this.ddlRoles.DataBind(); }
public IActionResult GetAll() { try { return(Ok(_rolesService.GetAll())); } catch (Exception e) { return(BadRequest(e.Message)); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; var list = rolesSvc.GetAll(); this.ddlRolesList.DataSource = list; this.ddlRolesList.DataTextField = "Roles_Title"; this.ddlRolesList.DataValueField = "Id"; this.ddlRolesList.DataBind(); }
public async Task <IActionResult> OnGet(int policyId) { var result = await PolicyService.GetById(policyId); ModelState.Merge(result); if (!ModelState.IsValid) { ShowMessage(CoreEnumerations.MessageTypes.danger, ModelState.GetErrors(" , ")); return(RedirectToPage("/Policies/Index", new { area = "UserManagementAdmin" })); } Input = result.Value; RolesList = RolesService.GetAll(); return(Page()); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } #region 绑定下拉列表 var data = rolesSvc.GetAll(); this.ddlRolesId.DataSource = data; this.ddlRolesId.DataTextField = "Roles_Title"; this.ddlRolesId.DataValueField = "Roles_Id"; this.ddlRolesId.DataBind(); #endregion }
public async Task GetAllTest() { var context = EssayCompetitionContextInMemoryFactory.InitializeContext(); var roleName1 = "Ninja1"; var roleName2 = "Ninja2"; await this.seeder.SeedRoleAsync(context, roleName1); await this.seeder.SeedRoleAsync(context, roleName2); var roleRepository = new EfDeletableEntityRepository <ApplicationRole>(context); var service = new RolesService(roleRepository); var resultedRoles = service.GetAll <RoleViewModel>(); Assert.True(resultedRoles.Any(x => x.Name == roleName1), "GetAll method does not work correctly"); Assert.True(resultedRoles.Any(x => x.Name == roleName2), "GetAll method does not work correctly"); }
public async Task <IActionResult> OnPostRemove(int id) { ModelState.Remove("Input.Name"); var result = await PolicyService.Delete(new ReturnResult <int> { Value = id }); ModelState.Merge(result); if (!ModelState.IsValid) { RolesList = RolesService.GetAll(); return(Page()); } ShowMessage(CoreEnumerations.MessageTypes.info, SharedResources.DeleteSuccess); return(RedirectToPage("/Policies/Index", new { area = "UserManagementAdmin" })); }
public async Task <IActionResult> OnPostSubmit() { if (!ModelState.IsValid) { RolesList = RolesService.GetAll(); return(Page()); } var result = await PolicyService.Save(new ReturnResult <PolicyViewModel>() { Value = Input }); ModelState.Merge(result); if (!ModelState.IsValid) { RolesList = RolesService.GetAll(); return(Page()); } ShowMessage(CoreEnumerations.MessageTypes.info, SharedResources.CreateSuccess); return(RedirectToPage(UserManagementNavConstants.Pages.PolicyIndex, new { area = UserManagementNavConstants.Area })); }
// public static IEnumerable<SelectListItem> FilldllPayPlanSetup() // { // var service = new PayPlanSetup(); // var PayPlanSetups = service.GetAll(); // var listitems = PayPlanSetups.Select(x => public static IEnumerable <SelectListItem> FillddlRoles() { var service = new RolesService(); var ethenics = service.GetAll(); var listitems = ethenics.Select(x => // new SelectListItem // { // Text = x.PayPlanSetupName, // Value = x.Id.ToString() // }); // return listitems; // } new SelectListItem { Text = x.RoleName, Value = x.Id.ToString() }); return(listitems); }
public List <Roles> GetAll() { return(rolesService.GetAll()); }
public ActionResult AllRoles() { return(this.Json(_rolesService.GetAll(), JsonRequestBehavior.AllowGet)); }
public ActionResult <List <GetRoleOutputDto> > List() { return(rolesService.GetAll().ToList()); }
// public static IEnumerable<SelectListItem> FilldllPayPlanSetup() // { // var service = new PayPlanSetup(); // var PayPlanSetups = service.GetAll(); // var listitems = PayPlanSetups.Select(x => public static IEnumerable<SelectListItem> FillddlRoles() { var service = new RolesService(); var ethenics = service.GetAll(); var listitems = ethenics.Select(x => // new SelectListItem // { // Text = x.PayPlanSetupName, // Value = x.Id.ToString() // }); // return listitems; // } new SelectListItem { Text = x.RoleName, Value = x.Id.ToString() }); return listitems; }
// GET: Roles public ActionResult Index() { return(View(service.GetAll())); }
public void OnGet() { RolesList = RolesService.GetAll(); }