Esempio n. 1
0
 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()));
 }
Esempio n. 2
0
 public void Execute(User args)
 {
     using (dynamic trans = _connection.Db().BeginTransaction())
     {
         trans.Users.UpdateById(args);
         trans.Commit();
     }
 }
Esempio n. 3
0
 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();
     }
 }
Esempio n. 4
0
        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;
            }
        }
Esempio n. 5
0
 public void Update(User user)
 {
     CheckCreateOrUpdateArguments(user);
     _updateUserCommand.Execute(user);
 }