Exemplo n.º 1
0
 public async Task <IEnumerable <Database.Imoveis> > GetImoveisAsync()
 {
     try
     {
         using (var ctx = new Database.SweetHomeEntities())
         {
             return(await Task.FromResult(ctx.Imoveis.ToList()));
         }
     }
     catch (Exception erro)
     {
         var idErro = Guid.NewGuid();
         //TODO: Log mensagem de erro
         throw new Exception("Ocorreu um problema ao recuperar a lista de imóveis. cod: " + idErro);
     }
 }
Exemplo n.º 2
0
 public async Task <Database.Imoveis> GetImovelAsync(Guid id)
 {
     try
     {
         using (var ctx = new Database.SweetHomeEntities())
         {
             return(await ctx.Imoveis.FindAsync(id));
         }
     }
     catch (Exception erro)
     {
         var idErro = Guid.NewGuid();
         //TODO: Log mensagem de erro
         throw new Exception("Ocorreu um problema ao recuperar a lista de imóveis. cod: " + idErro);
     }
 }
Exemplo n.º 3
0
        public async Task <bool> AddImovelAsync(Database.Imoveis imovel)
        {
            try
            {
                using (var ctx = new Database.SweetHomeEntities())
                {
                    ctx.Imoveis.Add(imovel);
                    await ctx.SaveChangesAsync();

                    return(true);
                }
            }
            catch (Exception erro)
            {
                var idErro = Guid.NewGuid();
                //TODO: Log mensagem de erro
                throw new Exception("Ocorreu um problema ao adicionar o imóvel. cod: " + idErro);
            }
        }