public async Task RegistrarAsync(Guid Id, string nome, string email, string celular, string cpf, DateTime dataNascimento, string cep) { var cliente = new Cliente() { Id = Id, Nome = nome, Email = email, Celular = celular, Cpf = cpf, DataNascimento = dataNascimento, Cep = cep }; var ValidationResult = new RegisterNewClienteValidation().Validate(cliente); if (!ValidationResult.IsValid) { NotificarValidacoesErro(ValidationResult); return; } var location = await _locationAppService.GetLocation(cliente.Cep); cliente.Latitude = location.lat; cliente.Longitude = location.lng; cliente.CurtaDescricao = "Olá, meu nome é " + cliente.Nome; cliente.LongaDescricao = "Olá, meu nome é " + cliente.Nome; // TODO: // Validacoes de negocio! cliente.Preferencia = new Preferencia() { Distancia = 150, IdadeMaxima = 65, IdadeMinima = 18, PrecoMinimo = 0, PrecoMaximo = 5000 }; cliente.Caracteristica = new Caracteristica() { LocalProprio = false, Valor1Hora = 0, Valor2horas = 0, Valor30min = 0, ValorPernoite = 0 }; _clienteRepository.Add(cliente); await _clienteRepository.SaveChangesAsync(); }
public async Task RegistrarAsync(ClienteViewModel clienteViewModel) { var cliente = _mapper.Map <Cliente>(clienteViewModel); var ValidationResult = new RegisterNewClienteValidation().Validate(cliente); if (!ValidationResult.IsValid) { NotificarValidacoesErro(ValidationResult); return; } // TODO: // Validacoes de negocio! var location = await _locationAppService.GetLocation(cliente.Cep); cliente.Latitude = location.lat; cliente.Longitude = location.lng; cliente.Preferencia = new Preferencia() { Distancia = 150, IdadeMaxima = 65, IdadeMinima = 18, PrecoMinimo = 0, PrecoMaximo = 5000 }; cliente.Caracteristica = new Caracteristica() { LocalProprio = false, Valor1Hora = 0, Valor2horas = 0, Valor30min = 0, ValorPernoite = 0 }; _clienteRepository.Add(cliente); await _clienteRepository.SaveChangesAsync(); }