示例#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;
         }
     }
 }
示例#2
0
 public static UserDoc NewUserDoc(this UserAdminModel model)
 {
     return(new UserDoc
     {
         Id = (model.Id == null) ? null : model.Id.Replace("-", "/"),
         Username = model.Username,
         Password = Database.Encrypt(model.Password),
         Email = model.Email,
         FirstName = model.FirstName,
         LastName = model.LastName,
         ExternalAccounts = null
     });
 }