public async Task ResetPassword(Entities.Emploee emp, string password) { if (string.IsNullOrEmpty(password)) { throw new ArgumentException("密码不能为空"); } emp.Password = sys.Runtime.RuntimeContext.PasswordHasher.HashPassword(password); await SqlStore.Default.SaveAsync(emp); }
public async Task NewEmploeeUser(Entities.Emploee emp, string account, string password) { if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(password)) { throw new ArgumentException("账户或密码不能为空"); } emp.Account = account; emp.Password = sys.Runtime.RuntimeContext.PasswordHasher.HashPassword(password); await SqlStore.Default.SaveAsync(emp); }
public async Task SaveEmploee(Entities.Emploee emp, Guid ouid) { //TODO:同步关联至相同员工的组织单元的名称 var ou = await EntityStore.LoadAsync <Entities.OrgUnit>(ouid); ou.Name = emp.Name; using (var txn = await Transaction.BeginAsync()) { await EntityStore.SaveAsync(emp, txn); await EntityStore.SaveAsync(ou, txn); await txn.CommitAsync(); } }
public async Task <Entities.OrgUnit> NewEmploee(Guid parentID) { if (parentID == Guid.Empty) { throw new Exception("新建员工时必须指定上级节点"); } //获取上级 var parent = await Entities.OrgUnit.LoadAsync(parentID); if (parent == null) { throw new Exception("新建员工时无法获取上级节点"); } if (parent.BaseType == Entities.Emploee.TypeId) { throw new Exception("无法在员工节点新建子节点"); } var emp = new Entities.Emploee(Guid.NewGuid()); emp.Name = "新员工"; var ou = new Entities.OrgUnit(Guid.NewGuid()); ou.Name = emp.Name; ou.BaseType = Entities.Emploee.TypeId; ou.BaseId = emp.Id; ou.ParentId = parentID; //保存并返回 using var conn = await SqlStore.Default.OpenConnectionAsync(); using var txn = conn.BeginTransaction(); await SqlStore.Default.SaveAsync(emp, txn); await SqlStore.Default.SaveAsync(ou, txn); txn.Commit(); return(ou); }
public async Task <Entities.OrgUnit> NewEmploee(Guid parentID) { if (parentID == Guid.Empty) { throw new Exception("新建员工时必须指定上级节点"); } //获取上级 var parent = await EntityStore.LoadAsync <Entities.OrgUnit>(parentID); if (parent == null) { throw new Exception("新建员工时无法获取上级节点"); } if (parent.BaseType == Entities.Emploee.TypeId) { throw new Exception("无法在员工节点新建子节点"); } var emp = new Entities.Emploee(); emp.Name = "新员工"; var ou = new Entities.OrgUnit(); ou.Name = emp.Name; ou.BaseType = Entities.Emploee.TypeId; ou.BaseId = emp.Id; ou.ParentId = parentID; //保存并返回 using (var txn = await Transaction.BeginAsync()) { await EntityStore.SaveAsync(emp, txn); await EntityStore.SaveAsync(ou, txn); await txn.CommitAsync(); } return(ou); }
public async Task SaveEmploee(Entities.Emploee emp, Guid ouid) { //TODO:同步关联至相同员工的组织单元的名称 var ou = await Entities.OrgUnit.LoadAsync(ouid); bool nameChanged = ou.Name != emp.Name; if (nameChanged) { ou.Name = emp.Name; } using var conn = await SqlStore.Default.OpenConnectionAsync(); using var txn = conn.BeginTransaction(); await SqlStore.Default.SaveAsync(emp, txn); if (nameChanged) { await SqlStore.Default.SaveAsync(ou, txn); } txn.Commit(); }
public async Task DeleteEmploeeUser(Entities.Emploee emp) { emp.Account = null; emp.Password = null; await SqlStore.Default.SaveAsync(emp); }