Exemplo n.º 1
0
 public UserViewModel(UserProfile user, List<Role> allRoles)
   : this()
 {
   _allRoles = allRoles;
   User = user;
   SelectedRoles = user.Roles.Select(r => r.RoleId).ToArray();      
 }
Exemplo n.º 2
0
    /// <summary>
    /// Updates the user or creates a new one
    /// </summary>
    /// <param name="siteUser">The site user.</param>
    public void UpdateUser(UserProfile siteUser)
    {
      ExecuteQuery(CACHE_KEY.FormatWith("User_Update_{0}".FormatWith(siteUser.UserId)),
        (con) =>
        {
          con.Execute(
            Properties.Resources.User_Update, siteUser);

          con.Execute(
              Properties.Resources.UserRole_Clear,
              new { UserId = siteUser.UserId });

          siteUser.Roles.ForEach(role =>
            con.Execute(
              Properties.Resources.UserRole_Update,
              new { UserId = siteUser.UserId, RoleId = role.RoleId })
          );

          Cache.RemoveFromCache(CACHE_KEY.FormatWith("User.*"));
        });
    }