public void Update(Guid UserId, UpdateUserCommand command, string userName)
        {
            var user = UserRepository.GetById(UserId);

            AssertConcern.AssertArgumentNotNull(user, "Usuário inexistente");
            AssertConcern.AssertArgumentTrue(user.Id == UserId.ToString(), "Usuário inválido para atualização");

            if (command.AccountType != -1)
            {
                AssertConcern.AssertArgumentEnumRange((int)command.AccountType, (int)AccountType.Normal, (int)AccountType.Companion, "Opção de conta inválida");
                user.AccountType = (AccountType)command.AccountType.Value;
            }

            if (!string.IsNullOrWhiteSpace(command.UrlProfilePhoto))
            {
                user.UrlProfilePhoto = command.UrlProfilePhoto;
            }

            user.UpdateBy  = userName;
            user.UpdatedAt = DateTime.UtcNow;
            UserRepository.Update(user);
            Uow.Commit();

            // SexMoveAuditing.Audit(new AuditCreateCommand("Usuário atualizado", new { User = user}));
        }
        public Guid Create(NewUserCommand command)
        {
            try
            {
                var existUser = UserRepository.GetByEmail(command.Email);

                if (existUser == null)
                {
                    existUser = UserRepository.GetByUserName(command.NickName);
                }

                AssertConcern.AssertArgumentTrue(existUser == null, "Usuário já cadastrado");

                var user = new User(command.NickName, command.Email, AccountType.Normal, SubscriptionType.Gratuity);
                user.GenerateNewId();
                user.PasswordHash = SecurityService.Encrypt(command.Password);
                UserRepository.Save(user);
                AssertConcern.AssertArgumentNotGuidEmpty(user.UserId, "Id do usuário de domínio criado incorretamente");

                Uow.Commit();

                return(user.UserId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void UpdatePhoto([FromUri] Guid fileId)
        {
            var files = this.GetPostedFiles();

            AssertConcern.AssertArgumentTrue(files.Count() > 0, "Informe o arquivo");
            var file = files.First();

            var user = UserAppService.GetDomainUserByEmail(User.Identity.Name);

            AssertConcern.AssertArgumentNotNull(user, "Usuário não encontrado");

            FileAppService.Update(new UpdateFileCommand()
            {
                FileId      = fileId,
                FileName    = file.FileName,
                File        = file.Content,
                ContentType = file.ContentType,
                UpdateUser  = User.Identity.Name,
                ReferenceId = user.UserId
            });
        }