Exemplo n.º 1
0
 public int Identity()
 {
     using (var db = new ViaCepContext())
     {
         return((from v in db.ViaCeps
                 orderby v.Id descending
                 select v.Id + 1).FirstOrDefault());
     }
 }
Exemplo n.º 2
0
 public List <ViaCepModel> Get()
 {
     using (var db = new ViaCepContext())
     {
         var query = (from v in db.ViaCeps
                      orderby v.DataHora descending
                      select v).Take(10);
         return(query.ToList <ViaCepModel>());
     }
 }
Exemplo n.º 3
0
 public void Save(ViaCepModel model)
 {
     try
     {
         using (var db = new ViaCepContext())
         {
             var viacep = new ViaCepModel();
             model.Id = Identity();
             db.ViaCeps.Add(model);
             db.SaveChanges();
         }
     }
     catch (System.Exception e)
     {
         throw;
     }
 }