public void UpdateUser(User user, Action<UpdateUserResult> callback) { _usersRunTarget.UpdateUser(_identity, user, callback); }
public InsertUserResult InsertUser(Identity identity, User user) { if (NotValid()) return InsertUserResult.Fail; return _project.UsersRunner.InsertUser(identity, user); }
public void LogOn(string name, string password, Action<bool> callback) { var p = PasswordConverter.ConvertBack(password); _usersRunTarget.LogOn(name, p, user => { if (user != null) { Current = user; _identity = new Identity(user.Id, user.Name, p); } callback.Invoke(user != null); }); }
public SetPasswordDialog(IUsers users, User user) { _users = users; _user = user; }
public UpdateUserResult UpdateUser(Identity identity, User user) { if (NotValid()) return UpdateUserResult.Fail; return _project.UsersRunner.UpdateUser(identity, user); }
public InsertUserResult InsertUser(Identity identity, User user) { if (!IsUserEditor(identity)) return InsertUserResult.Fail; using (var connection = _connectionFactory.Create()) { return _repository.InsertUser(connection, user); } }
protected override void EstablishContext() { base.EstablishContext(); Service = new Mock<IService>(); User = new User(); Service.Setup(s => s.LogOn(Name, Password)).Returns(User); }
protected override void EstablishContext() { base.EstablishContext(); Name = "Name"; Password = "******"; User = new User(); UsersRunner.Setup(r => r.LogOn(Name, Password)).Returns(User); }
public void Insert(NpgsqlConnection connection, User[] users, string[] passwords) { var columns = new[] { DbStr.Id, DbStr.Name, DbStr.Description, DbStr.Photo, DbStr.Password, DbStr.Enabled, DbStr.CanChange, DbStr.Privilege }; var values = users.Select((u, i) => new object[] { u.Id, u.Name, u.Description, u.Photo, passwords[i], u.Enabled, u.CanChange, u.Privilege }).ToArray(); _npgHelper.ExecuteNonQuery(connection, _npgQueryHelper.Insert(DbStr.Users, columns, values)); }
public void UpdateUser(Identity identity, User user, Action<UpdateUserResult> callback) { _queue.Enqueue(service => callback(service.UpdateUser(identity, user))); }
public EditUserDialog(IUsers users, User user) { _users = users; _user = new User(); _user.UpdateFrom(user); }
public void InsertUser(Identity identity, User user, Action<InsertUserResult> callback) { _queue.Enqueue(service => callback(service.InsertUser(identity, user))); }
protected override void EstablishContext() { base.EstablishContext(); User = new User {Name = Name}; UserActions.Single().Invoke(User); }
private void Callback(User result) { Result = result; }
public void InsertUser(User user, Action<InsertUserResult> callback) { _usersRunTarget.InsertUser(_identity, user, callback); }
public InsertUserResult InsertUser(NpgsqlConnection connection, User user) { try { var count = _npgHelper.ExecuteNonQuery(connection, _npgQueryHelper.Insert( DbStr.Users, new[] { DbStr.Id, DbStr.Name, DbStr.Description, DbStr.Photo, DbStr.Enabled, DbStr.CanChange, DbStr.Privilege }, new[] { new object[] { user.Id, user.Name, user.Description, user.Photo, user.Enabled, user.CanChange, user.Privilege } })); return count == 1 ? InsertUserResult.Success : InsertUserResult.Fail; } catch (NpgsqlException exception) { switch (exception.Code) { case "23505": return exception.Detail.Contains(DbStr.Id) ? InsertUserResult.IdConflict : InsertUserResult.NameConflict; case "23502": return InsertUserResult.NullValue; default: return InsertUserResult.Fail; } } }
public void LogOff() { _identity = null; Current = null; }
public UpdateUserResult UpdateUser(NpgsqlConnection connection, User user) { try { var count = _npgHelper.ExecuteNonQuery(connection, _npgQueryHelper.UpdateWhere( DbStr.Users, new Eq(DbStr.Id, user.Id), new[] { DbStr.Name, DbStr.Description, DbStr.Photo, DbStr.Enabled, DbStr.CanChange, DbStr.Privilege }, new object[] { user.Name, user.Description, user.Photo, user.Enabled, user.CanChange, user.Privilege })); return count == 1 ? UpdateUserResult.Success : UpdateUserResult.UserNotFound; } catch (NpgsqlException exception) { switch (exception.Code) { case "23505": return UpdateUserResult.NameConflict; case "23502": return UpdateUserResult.NullValue; default: return UpdateUserResult.Fail; } } }
public AddUserDialog(IUsers users, long id) { _users = users; _user = new User { Id = id }; }
public void UpdateFrom(User user) { Id = user.Id; Name = user.Name; Description = user.Description; Photo = user.Photo; Enabled = user.Enabled; CanChange = user.CanChange; Privilege = user.Privilege; }