示例#1
0
        public void ForgotPassword(ForgotPasswordCommand command)
        {
            var user = UserRepository.GetByEmail(command.Email);

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

            var passwordKey = UserService.GeneratePasswordKey(user);

            UserRepository.SavePasswordKey(user.UserId, passwordKey);

            var sB = new StringBuilder();

            sB.Append("Olá, <br/>").AppendLine()
            .Append(" Para recuperar a senha utilize esse código: <br/>").AppendLine()
            .Append($"<p> <strong>{passwordKey}</strong> </p> ").AppendLine()
            .Append("<br/>").AppendLine()
            .Append("Atenciosamente, <br/>").AppendLine()
            .Append("Equipe SexMove");

            var emailService = new EmailService();

            emailService.SendEmail(sB.ToString(), "SexMove - Recuperar senha", user.Email);

            Uow.Commit();
        }
示例#2
0
        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}));
        }
示例#3
0
        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;
            }
        }
示例#4
0
文件: Produto.cs 项目: Cacuci/DDD
 public void Validar()
 {
     AssertConcern.Empty(value: Nome, message: "O campo Nome do produto não pode estar vazio");
     AssertConcern.Empty(value: Descricao, message: "O campo Descricao do produto não pode estar vazio");
     AssertConcern.Equals(object1: CategoriaID, object2: Guid.Empty, "O campo CategoriaID do produto não pode estar vazio");
     AssertConcern.SmallEquallMin(value: Valor, min:  0, "O campo Valor do produto não pode se menor igual a 0");
     AssertConcern.Empty(value: Imagem, message: "O campo Imagem do produto não pode estar vazio");
 }
示例#5
0
        public void RemoveFile([FromUri] Guid fileId)
        {
            var user = UserAppService.GetDomainUserByEmail(User.Identity.Name);

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

            FileAppService.Remove(fileId, User.Identity.Name);
        }
示例#6
0
文件: Dimensoes.cs 项目: Cacuci/DDD
        public Dimensoes(decimal altura, decimal largura, decimal profundidade)
        {
            AssertConcern.SmallThatlMin(value: altura, min: 1, message: "O campo Altura não pode ser menor ou igual a 0");
            AssertConcern.SmallThatlMin(value: largura, min: 1, message: "O campo Largura não pode ser menor ou igual 0");
            AssertConcern.SmallThatlMin(value: profundidade, min: 1, message: "O campo Profundidade não pode ser menor ou igual 0");

            Altura       = altura;
            Largura      = largura;
            Profundidade = profundidade;
        }
示例#7
0
        public IEnumerable <FileDto> GetVideos()
        {
            var user = UserAppService.GetDomainUserByEmail(User.Identity.Name);

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

            return(FileAppService.GetFiles(new GetFilesCommand()
            {
                ReferenceId = user.UserId, ContentType = "video"
            }));
        }
示例#8
0
        public void Remove(Guid fileId, string deleteUser)
        {
            AssertConcern.AssertArgumentNotGuidEmpty(fileId, "Identificador do arquivo inválido");
            AssertConcern.AssertArgumentNotEmpty(deleteUser, "Usuário inválido para remover arquivos");

            var file = FileRepository.GetById(fileId);

            AssertConcern.AssertArgumentNotNull(file, "Arquivo não encontrado");

            FileRepository.Remove(file, deleteUser);

            Uow.Commit();
        }
示例#9
0
        public void ResetPassword(ResetPasswordCommand command)
        {
            var user = UserRepository.GetByEmail(command.Email);

            AssertConcern.AssertArgumentNotNull(user, "Usuário não encontrado");
            AssertConcern.AssertArgumentEquals(user.PasswordResetKey, command.PasswordResetKey, "Código inválido para resetar senha");
            AssertConcern.AssertArgumentNotNull(command.NewPassword, "A nova senha não pode estar nula");
            AssertConcern.AssertArgumentNotEmpty(command.NewPassword, "A nova senha não pode ser vazio");

            var newPassword = SecurityService.Encrypt(command.NewPassword);

            user.SetPasswordResetKey(newPassword);
            user.PasswordHash = newPassword;

            UserRepository.Update(user);
            Uow.Commit();
        }
示例#10
0
        public void Update(UpdateFileCommand command)
        {
            AssertConcern.AssertArgumentNotGuidEmpty(command.FileId, "Identificador do arquivo inválido");

            var file = FileRepository.GetById(command.FileId);

            AssertConcern.AssertArgumentNotNull(file, "Arquivo não encontrado");

            file.Name        = command.FileName;
            file.ContentType = command.ContentType;
            file.ReferenceId = command.ReferenceId.Value;
            file.Size        = command.File.Length;

            FileRepository.Update(file, command.UpdateUser);
            AzureContainer.AddFile($"{file.Id}_{file.Name}", command.File);

            Uow.Commit();
        }
示例#11
0
        public void UploadNewFile()
        {
            var user = UserAppService.GetDomainUserByEmail(User.Identity.Name);

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

            foreach (var file in this.GetPostedFiles())
            {
                FileAppService.Upload(new AddFileCommand()
                {
                    FileName    = file.FileName,
                    File        = file.Content,
                    ContentType = file.ContentType,
                    CreateUser  = user.UserName,
                    ReferenceId = Guid.Parse(user.Id)
                });
            }
        }
示例#12
0
        public ProfileDto GetUserProfile(Guid userId)
        {
            AssertConcern.AssertArgumentNotGuidEmpty(userId, "Id do usuário inválido");
            var profile = ProfileRepository.GetByUserId(userId.ToString());

            if (profile == null)
            {
                return(new ProfileDto()
                {
                    UserId = userId.ToString()
                });
            }

            var returnProfile = new ProfileDto()
            {
                Id                               = profile.Id,
                UserId                           = profile.UserId,
                Genre                            = (int)profile.Genre,
                GenreDescription                 = profile.Genre.ToString(),
                MaritalStatus                    = (int)profile.MaritalStatus,
                MaritalStatusDescription         = profile.MaritalStatus.ToString(),
                ZipCode                          = profile.ZipCode,
                MaritalStatusInterest            = (int)profile.MaritalStatusInterest,
                MaritalStatusInterestDescription = profile.MaritalStatusInterest.ToString(),
                Summary                          = profile.Summary,
                Interests                        = new List <Configuration>(),
                Relationships                    = new List <Configuration>()
            };

            var interestConfigurations     = ConfigurationRepository.GetByQuery(profile.UserId, "Interest");
            var relationshipConfigurations = ConfigurationRepository.GetByQuery(profile.UserId, "Relationship");

            if (interestConfigurations.Any())
            {
                Parallel.ForEach(interestConfigurations, x => returnProfile.Interests.Add(x));
            }

            if (relationshipConfigurations.Any())
            {
                Parallel.ForEach(relationshipConfigurations, x => returnProfile.Relationships.Add(x));
            }

            return(returnProfile);
        }
示例#13
0
        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
            });
        }
示例#14
0
        public void Upload(AddFileCommand command)
        {
            AssertConcern.AssertArgumentNotEmpty(command.FileName, "Nome do arquivo não pode ser nulo");

            var fileAlreadyExist = FileRepository.GetFilesByQuery(command.FileName);

            var file = new File(command.FileName, command.ContentType)
            {
                Size        = command.File.Length,
                CreatedAt   = DateTime.UtcNow,
                CreateBy    = command.CreateUser,
                UpdatedAt   = DateTime.UtcNow,
                UpdateBy    = command.CreateUser,
                ReferenceId = command.ReferenceId.Value
            };

            file.GenerateNewId();

            FileRepository.Save(file, command.CreateUser);
            AzureContainer.AddFile($"{file.Id}_{file.Name}", command.File);

            Uow.Commit();
        }
示例#15
0
 public void Validar()
 {
     AssertConcern.Empty(value: Nome, message: "O campo Nome da categoria não pode estar vazio");
     AssertConcern.Equals(object1: Codigo, object2: 0, message: "O campo Codigo não pode ser 0");
 }
示例#16
0
        public void UpdateProfile(Guid UserId, UpdateProfileCommand command, string userName)
        {
            AssertConcern.AssertArgumentNotGuidEmpty(UserId, "Usuário inválido");

            var profile = ProfileRepository.GetByUserId(UserId.ToString());

            if (profile == null)
            {
                var genre      = (TypePerson)command.Genre;
                var newProfile = new Profile(UserId.ToString(), genre);
                newProfile.GenerateNewId();
                newProfile.Genre                 = genre;
                newProfile.MaritalStatus         = (MaritalStatus)command.MaritalStatus;
                newProfile.ZipCode               = command.ZipCode;
                newProfile.MaritalStatusInterest = (MaritalStatus)command.MaritalStatusInterest;
                newProfile.Summary               = command.Summary;

                ProfileRepository.Save(newProfile, userName);
            }
            else
            {
                AssertConcern.AssertArgumentNotNull(profile, "Perfil não encontrado");
                AssertConcern.AssertArgumentNotNull(profile.UserId, "Usuário não encontrado");
                profile.Genre                 = (TypePerson)command.Genre;
                profile.MaritalStatus         = (MaritalStatus)command.MaritalStatus;
                profile.ZipCode               = profile.ZipCode;
                profile.MaritalStatusInterest = (MaritalStatus)command.MaritalStatusInterest;
                profile.Summary               = command.Summary;
                ProfileRepository.Update(profile, userName);
            }

            if (command.Interests != null && command.Interests.Count > 0)
            {
                foreach (var item in command.Interests)
                {
                    var configuration = ConfigurationRepository.Get(item.UserId, item.Key);
                    if (configuration == null)
                    {
                        ConfigurationRepository.Create(item);
                    }

                    else
                    {
                        configuration.Value = item.Value;
                        ConfigurationRepository.Update(configuration);
                    }
                }
            }

            if (command.Relationships != null && command.Relationships.Count > 0)
            {
                foreach (var item in command.Relationships)
                {
                    var configuration = ConfigurationRepository.Get(item.UserId, item.Key);
                    if (configuration == null)
                    {
                        ConfigurationRepository.Create(item);
                    }
                    else
                    {
                        configuration.Value = item.Value;
                        ConfigurationRepository.Update(configuration);
                    }
                }
            }

            Uow.Commit();
        }