Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Utils.LoggedUser == null)
            {
                Response.Redirect("~/login");
            }
            if (!IsPostBack)
            {
                if (Utils.CheckPermission(1, 3, Utils.LoggedUser.Roles) < 1)
                {
                    ClientScript.RegisterStartupScript(GetType(), "alert", "lmis.notification.error('" + GetGlobalResourceObject("MessagesResource", "X_NotAuthorized") + @"');", true);

                    return;
                }
                var result = Mgr.GetUsersAdmin();
                ddlUsers.DataSource     = result;
                ddlUsers.DataTextField  = "UserName";
                ddlUsers.DataValueField = "UserId";
                ddlUsers.DataBind();



                ApplicationDbContext context = Context.GetOwinContext().Get <ApplicationDbContext>();
                var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
                var resultRoles = roleManager.Roles.ToList();
                chkRoles.DataSource     = resultRoles;
                chkRoles.DataTextField  = "Name";
                chkRoles.DataValueField = "id";
                chkRoles.DataBind();
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Utils.LoggedUser == null)
            {
                Response.Redirect("~/login");
            }
            if (Utils.CheckPermission(1, 1, Utils.LoggedUser.Roles) < 1)
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "lmis.notification.error('" + GetGlobalResourceObject("MessagesResource", "X_NotAuthorized") + @"');", true);

                return;
            }
            var result = Mgr.GetUsersAdmin();

            gvregister.DataSource = result;
            gvregister.DataBind();
        }
Пример #3
0
 public static object Post(OrganizationVM organizationObject, bool validateOnly)
 {
     try
     {
         var manager = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
         manager.UserValidator = new UserValidator <ApplicationUser>(manager)
         {
             AllowOnlyAlphanumericUserNames = false,
             RequireUniqueEmail             = true
         };
         manager.PasswordValidator = new PasswordValidator()
         {
             RequiredLength          = 3,
             RequireNonLetterOrDigit = false,
             RequireDigit            = false,
             RequireLowercase        = false,
             RequireUppercase        = false
         };
         IdentityResult userResult;
         var            user = new ApplicationUser()
         {
             UserName = organizationObject.User.UserName, Email = organizationObject.User.Email, PhoneNumber = organizationObject.User.PhoneNumber
         };
         userResult = manager.Create(user, organizationObject.User.Password);
         ModelResponse mr = null;
         if (userResult.Succeeded)
         {
             var result = userManager.GetUsersAdmin();
             mr = organizationManager.Post(ref organizationObject, user.Id);
         }
         return(Utils.ServiceResponse(pageCode, mr));
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }