Esempio n. 1
0
 public static void Load(this UserDoc doc, UserAdminModel model)
 {
     if ((doc != null) && (model != null))
     {
         if (!string.IsNullOrEmpty(model.Username) && (model.Username != doc.Username))
         {
             doc.Username = model.Username;
         }
         if (!string.IsNullOrEmpty(model.Password) && (model.Password != doc.Password))
         {
             doc.Password = Database.Encrypt(model.Password);
         }
         if (!string.IsNullOrEmpty(model.Email) && (model.Email != doc.Email))
         {
             doc.Email = model.Email;
         }
         if (!string.IsNullOrEmpty(model.FirstName) && (model.Username != doc.FirstName))
         {
             doc.FirstName = model.FirstName;
         }
         if (!string.IsNullOrEmpty(model.LastName) && (model.Username != doc.LastName))
         {
             doc.LastName = model.LastName;
         }
     }
 }
Esempio n. 2
0
 public static UserModel NewUser(this UserDoc doc)
 {
     return((doc == null) ? null :
            new UserModel
     {
         Id = doc.Id,
         Username = doc.Username,
         Email = doc.Email,
         FirstName = doc.FirstName,
         LastName = doc.LastName,
         ExternalAccount = null
     });
 }
Esempio n. 3
0
 public static UserAdminModel NewUserAdmin(this UserDoc doc)
 {
     return((doc == null) ? null :
            new UserAdminModel
     {
         Id = doc.Id.Replace("/", "-"),
         Username = doc.Username,
         Password = doc.Password,
         Email = doc.Email,
         FirstName = doc.FirstName,
         LastName = doc.LastName,
         IsAdmin = doc.IsAdmin()
     });
 }
Esempio n. 4
0
 public static bool IsAdmin(this UserDoc user)
 {
     return(Database.Has <AdminDoc>(admin =>
                                    admin.UserId == user.Id));
 }