public static bool Add(Category c) { try { using (Book_Sale_ManagerEntities context = new Book_Sale_ManagerEntities()) { context.Categories.Add(c); context.SaveChanges(); Console.WriteLine("[Category Add Successful!]" + c.name); context.Dispose(); return(true); } } catch (Exception e) { LogService.log("Error", e.Message); Console.WriteLine(e.StackTrace); return(false); } }
public static bool Remove(Category c) { try { using (Book_Sale_ManagerEntities context = new Book_Sale_ManagerEntities()) { Category category = context.Categories.FirstOrDefault(t => t.ID == c.ID); context.Categories.Remove(category); context.SaveChanges(); Console.WriteLine("[Category Remove Successful!]" + c.name); context.Dispose(); return(true); } } catch (Exception e) { LogService.log("Error", e.Message); return(false); } }