public string ProvideUserData(User user) { return String.Format("{0}^{1}^{2}^{3}", user.Id, user.OrganizationId.HasValue ? user.OrganizationId.Value.ToString() : "none", String.Format("{0} {1}", user.FirstName, user.LastName), String.Join("$", user.Roles.ToArray())); }
public void Execute(User args) { using (dynamic trans = _connection.Db().BeginTransaction()) { trans.Users.UpdateById(args); trans.Commit(); } }
public void Execute(User args) { using (dynamic trans = _connection.Db().BeginTransaction()) { var defaultRole = trans.Roles.FindAllByName(Role.OrganizationUser).FirstOrDefault(); trans.Users.Insert(args); trans.UsersRoles.Insert(UserId: args.Id, RoleId: !args.RoleId.HasValue ? defaultRole.Id : args.RoleId.Value); trans.Commit(); } }
private void CheckCreateOrUpdateArguments(User user) { var otherWithUserName = _getUserByUsernameQuery.Execute(user.UserName); var otherWithEmail = _getUserByEmailQuery.Execute(user.EmailAddress); if (otherWithEmail != null || otherWithUserName != null) { var ex = new ApplicationValidationException(); if(otherWithUserName != null) { ex.AddError("UserName", "The user name selected is not available."); } if(otherWithEmail != null) { ex.AddError("EmailAddress", "The email address selected is not available."); } throw ex; } }
public void Update(User user) { CheckCreateOrUpdateArguments(user); _updateUserCommand.Execute(user); }