public int Create(Category category) { using (_dbContext = new ProductsEntities()) { _dbContext.Categories.Add(category); var result = _dbContext.SaveChanges(); return (result > 0) ? category.ID : -1; } }
public int Update(Category category) { Category dbCategory; var result = -1; using (_dbContext = new ProductsEntities()) { dbCategory = _dbContext.Categories.FirstOrDefault(p => p.ID == category.ID); } if (dbCategory != null) { MapCategory(dbCategory, category); using (_dbContext = new ProductsEntities()) { _dbContext.Entry(category).State = System.Data.Entity.EntityState.Modified; result = _dbContext.SaveChanges(); } } return result; }
public void InsertIntoCategories(Category tuple) { DB.Categories.InsertOnSubmit(tuple); if (AutoCommit) DB.SubmitChanges(); }
partial void DeleteCategory(Category instance);
partial void UpdateCategory(Category instance);
partial void InsertCategory(Category instance);
private void MapCategory(Category CategoryToMap, Category CategoryMapper) { CategoryToMap.Name = CategoryMapper.Name; }
public void InsertCategory(Category tuple) { md.InsertIntoCategories(tuple); }