public string Update(T model) { using (Cs20483Context context = new Cs20483Context()) { context.Entry <T>(model).State = EntityState.Modified; context.SaveChanges(); } return("Alterado com sucesso"); }
public string Create(T model) { using (Cs20483Context context = new Cs20483Context()) { context.Set <T>().Add(model); context.SaveChanges(); } return("Inserido com sucesso"); }
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"); }