Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void LoadRoles(string roleName)
 {
     if (string.IsNullOrEmpty(roleName))
     {
         RolesList = RolesService.GetAll();
     }
 }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 6
0
 public IActionResult GetAll()
 {
     try
     {
         return(Ok(_rolesService.GetAll()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        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());
        }
Exemplo n.º 9
0
        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
        }
Exemplo n.º 10
0
        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");
        }
Exemplo n.º 11
0
        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" }));
        }
Exemplo n.º 12
0
        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 }));
        }
Exemplo n.º 13
0
        // 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);
        }
Exemplo n.º 14
0
 public List <Roles> GetAll()
 {
     return(rolesService.GetAll());
 }
Exemplo n.º 15
0
 public ActionResult AllRoles()
 {
     return(this.Json(_rolesService.GetAll(), JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 16
0
 public ActionResult <List <GetRoleOutputDto> > List()
 {
     return(rolesService.GetAll().ToList());
 }
Exemplo n.º 17
0
        // 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;
        }
Exemplo n.º 18
0
 // GET: Roles
 public ActionResult Index()
 {
     return(View(service.GetAll()));
 }
Exemplo n.º 19
0
 public void OnGet()
 {
     RolesList = RolesService.GetAll();
 }