public void Add(CategoryDebate categoryDebate) { try { using (var context = new dezbateriEntities()) { context.CategoryDebates.Add(categoryDebate); context.SaveChanges(); } } catch (Exception ex) { throw new CategoryDebateException("Add", ex); } }
public void Update(CategoryDebate categoryDebate) { try { using (var context = new dezbateriEntities()) { var categoryDebateUpdated = context.CategoryDebates.FirstOrDefault(categoryDebateObj => categoryDebateObj.debate_id == categoryDebate.debate_id); if (categoryDebateUpdated == null) { throw new CategoryDebateException("No categoryDebate found"); } categoryDebateUpdated.category_id = categoryDebate.category_id; context.SaveChanges(); } } catch (Exception ex) { throw new CategoryDebateException("Update", ex); } }