Exemple #1
0
        private void CreateUsers()
        {
            if (!_identityContext.Users.Any())
            {
                var user = new ApplicationUser {
                    UserName = "******", Name = "Admin", Email = "*****@*****.**", EmailConfirmed = true, CreatedDate = DateTime.Now, IsEnabled = true
                };
                _userManager.CreateAsync(user, "P@ssw0rd!").Result.ToString();
                _userManager.AddToRoleAsync(_userManager.FindByNameAsync("*****@*****.**").GetAwaiter().GetResult(), "Admin").Result.ToString();

                // _userManager.CreateAsync(new ApplicationUser { UserName = "******", Name = "user", Email = "*****@*****.**", EmailConfirmed = true, CreatedDate = DateTime.Now, IsEnabled = true }, "P@ssw0rd!").Result.ToString();
                //_userManager.AddToRoleAsync(_userManager.FindByNameAsync("*****@*****.**").GetAwaiter().GetResult(), "User").Result.ToString();
                var model = new ViewModels.ClienteViewModel()
                {
                    Id                    = Guid.Parse(user.Id),
                    Nome                  = "Admin",
                    Email                 = user.Email,
                    Celular               = "31988616936",
                    Cpf                   = "05627810645",
                    DataNascimento        = new DateTime(1983, 02, 13),
                    Cep                   = "35970000",
                    CurtaDescricao        = "Olá, eu sou o admin",
                    EstaOferecendo        = true,
                    Genero                = Domain.Clientes.EnumGenero.Homem,
                    LongaDescricao        = "essa é minha descrição longa",
                    Nota                  = 1,
                    NotaAmbiente          = 1,
                    NotaEducacao          = 1,
                    NotaFidelidadeAsFotos = 1,
                    NotaHigiene           = 1,
                    NotaPontualidade      = 1,
                    NotaPrazer            = 1,
                };

                _clienteService.RegistrarAsync(model).GetAwaiter().GetResult();
            }
        }
Exemple #2
0
        private void AddClientes()
        {
            if (!_context.Clientes.Any(q => q.Nome.Contains("garota")))
            {
                Random random = new Random();
                for (var i = 1; i <= 26; i++)
                {
                    var user = new ApplicationUser {
                        UserName = $"garota{i}@admin.com", Name = $"garota{i}", Email = $"garota{i}@lust.com", EmailConfirmed = true, CreatedDate = DateTime.Now, IsEnabled = true
                    };
                    _userManager.CreateAsync(user, "P@ssw0rd!").Result.ToString();

                    var model = new ViewModels.ClienteViewModel()
                    {
                        Id                    = Guid.Parse(user.Id),
                        Nome                  = $"garota{i}",
                        Email                 = user.Email,
                        Celular               = "31988616936",
                        Cpf                   = "05627810645",
                        DataNascimento        = new DateTime(2001 - i, 01, 01),
                        Cep                   = ceps[i - 1],
                        CurtaDescricao        = "Olá, eu sou a garota " + i,
                        EstaOferecendo        = true,
                        Genero                = Domain.Clientes.EnumGenero.Mulher,
                        LongaDescricao        = "essa é minha descrição longa",
                        Nota                  = (decimal)random.NextDouble(),
                        FotoDeCapa            = Guid.NewGuid(),
                        FotoDePerfil          = Guid.NewGuid(),
                        NotaAmbiente          = (decimal)random.NextDouble(),
                        NotaEducacao          = (decimal)random.NextDouble(),
                        NotaFidelidadeAsFotos = (decimal)random.NextDouble(),
                        NotaHigiene           = (decimal)random.NextDouble(),
                        NotaPontualidade      = (decimal)random.NextDouble(),
                        NotaPrazer            = (decimal)random.NextDouble(),
                    };

                    _clienteService.RegistrarAsync(model).GetAwaiter().GetResult();


                    var cliente = _context.Clientes
                                  .Include(q => q.Caracteristica)
                                  .Single(q => q.Id == model.Id);


                    cliente.Caracteristica.LocalProprio  = false;
                    cliente.Caracteristica.Valor1Hora    = 100 + 10 * i;
                    cliente.Caracteristica.Valor2horas   = 200 + 10 * i;
                    cliente.Caracteristica.Valor30min    = 50 + 10 * i;
                    cliente.Caracteristica.ValorPernoite = 500 + 10 * i;

                    _context.SaveChanges();

                    var stream = new FileStream(Directory.GetCurrentDirectory() + $"\\extra\\fotos\\{i}.jpg", FileMode.Open);
                    _clienteService.AddFotoAsync(model.Id, model.FotoDePerfil.Value, "minha foto de perfil", stream).GetAwaiter().GetResult();
                    stream.Close();

                    stream = new FileStream(Directory.GetCurrentDirectory() + $"\\extra\\fotos\\capa.jpg", FileMode.Open);
                    _clienteService.AddFotoAsync(model.Id, model.FotoDeCapa.Value, "minha foto de capa", stream).GetAwaiter().GetResult();
                    stream.Close();

                    stream = new FileStream(Directory.GetCurrentDirectory() + $"\\extra\\fotos\\extra.jpg", FileMode.Open);
                    _clienteService.AddFotoAsync(model.Id, Guid.NewGuid(), "minha foto de extra", stream).GetAwaiter().GetResult();
                    stream.Close();
                }
            }
        }