public void Save(Account account) { if (string.IsNullOrEmpty(account.Username)) { throw new ArgumentException("用户名不能为空!"); } if (account.AccountId > 0) { var tmp = Dao.GetAccount(account.AccountId); if (tmp != null && tmp.AccountId != account.AccountId) { throw new ArgumentException("用户名已被使用!"); } Dao.Update(account); } else { if (string.IsNullOrEmpty(account.Password)) { throw new ArgumentException("密码不能为空!"); } Dao.Create(account); } UpdateCache(account); }
public void CreateTest() { Account account = new Account { Username = "******", Password = "******", Role = (short)Role.Administrator, TrueName = "Admin", }; target.Create(account); var expect = target.GetAccount(account.Username, "123"); Assert.AreNotEqual(0, expect.AccountId); }
/// <summary> /// 创建账号数据模型信息 /// </summary> /// <param name="accout">账号</param> /// <param name="password">密码</param> public void Create(string account, string password) { //AccountModel model = new AccountModel(id.Add_Get(), account, password); //accModelDict.Add(model.Account, model); accountDao.Create(account, password); }