/// <summary> /// Create attribute, if present, after item is created /// </summary> /// <param name="item">Base item just created from datastore</param> public void OnItemCreate(Item item) { if (item.HasData <AccountData>()) { var data = item.GetData <AccountData>(); data.DataItemId = item.Id; AccountDataRepo.Create(data); } }
/// <summary> /// Create a new account /// </summary> /// <param name="name">Login name</param> /// <param name="password">Login password</param> /// <param name="temporary">Account is temporary for trial purposes</param> /// <param name="admin">Account has administrative rights</param> public AccountData Create( string name, string password, bool temporary = false, bool admin = false) { var account = AccountDataRepo.Create(new List <AccountData>() { new AccountData() { Name = name, Password = BCrypt.Net.BCrypt.HashPassword(password), Temporary = temporary, Admin = admin } }).FirstOrDefault(); return(account); }