Guest User

Guest User

  • Tech Writer
  • 98
  • 42.4k

Update doesnt work

Dec 10 2020 12:57 AM
Hi this is my code.. I just wonder if why I still encounter error in Category.Update even if the model is mapped all fields with Repository. The Category.Add works..
  1. protected DbContext _context { getset; }  
  2. public SupplierService(DbContext context){  
  3. _context = context;  
  4. }  
  5. public void Create(CategoryModel model){  
  6. _context.Categorys.Add(model.CovertToRepository());  
  7. _context.SaveChanges();  
  8. }  
  9. public void Edit(CategoryModel model){  
  10. _context.Category.Update(model.ConvertToRepository());  
  11. _context.SaveChanges();  
  12. }

Answers (1)