public void AddCategory(Categories ent) { var exists = from t in bjDB.Categories where t.CategoryId == ent.CategoryId select t; if (exists.Count() == 0) { bjDB.Categories.InsertOnSubmit(ent); AllCategories.Add(ent); } else { Categories t = exists.FirstOrDefault(); t.Title = ent.Title; t.OffersCount = ent.OffersCount; } bjDB.SubmitChanges(); }
public void DeleteCategory(Categories ent) { AllCategories.Remove(ent); bjDB.Categories.DeleteOnSubmit(ent); bjDB.SubmitChanges(); }