public void UpdateCategory(CategoryViewModel categoryViewModel) { foreach(Category c in categoryViewModel.ListCategory) { db.Entry(c).State = EntityState.Modified; } try { db.SaveChanges(); } catch(Exception e) { log.Error("Error Update Category : " + e.Message, e); } }
public void InsertCategory(CategoryViewModel categoryViewModel) { List<Category> lCategory = categoryViewModel.ListCategory; foreach(Category c in lCategory) { db.Category.Add(c); } try { db.SaveChanges(); } catch(Exception e) { log.Error("Error Insert Category : " + e.Message, e); } }