Пример #1
0
 public string Update(T model)
 {
     using (Cs20483Context context = new Cs20483Context())
     {
         context.Entry <T>(model).State = EntityState.Modified;
         context.SaveChanges();
     }
     return("Alterado com sucesso");
 }
Пример #2
0
 public string Create(T model)
 {
     using (Cs20483Context context = new Cs20483Context())
     {
         context.Set <T>().Add(model);
         context.SaveChanges();
     }
     return("Inserido com sucesso");
 }
Пример #3
0
 public string Delete(int id)
 {
     using (Cs20483Context context = new Cs20483Context())
     {
         T model = GetById(id);
         context.Entry <T>(model).State = EntityState.Deleted;
         context.Set <T>().Remove(model);
         context.SaveChanges();
     }
     return("Deletado com sucesso");
 }