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; } } }
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 }); }
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() }); }
public static bool IsAdmin(this UserDoc user) { return(Database.Has <AdminDoc>(admin => admin.UserId == user.Id)); }