예제 #1
0
        public Task Message(DataHudComunication message)
        {
            if (message.to != null && message.to != default(Guid))
            {
                message.from = Guid.Parse(this.Context.User.GetUserId());
                _context.Dialogos.Add(new Dialogo()
                {
                    Id        = message.id,
                    ChatId    = message.chatId,
                    ClienteId = message.from,
                    Mensagem  = message.message
                });
                _context.SaveChanges();

                return(Clients.User(message.to.ToString()).SendAsync("Message", message));
            }


            return(Clients.All.SendAsync("Message", message));
        }
예제 #2
0
 public int SaveChanges()
 {
     return(Db.SaveChanges());
 }
예제 #3
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();
                }
            }
        }