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;
 }
示例#3
0
文件: mainDal.cs 项目: T4g1/3eme
 public void InsertIntoCategories(Category tuple) {
     DB.Categories.InsertOnSubmit(tuple);
     if (AutoCommit)
         DB.SubmitChanges();
 }
示例#4
0
 partial void DeleteCategory(Category instance);
示例#5
0
 partial void UpdateCategory(Category instance);
示例#6
0
 partial void InsertCategory(Category instance);
 private void MapCategory(Category CategoryToMap, Category CategoryMapper)
 {
     CategoryToMap.Name = CategoryMapper.Name;
 }
示例#8
0
文件: BLL.cs 项目: T4g1/3eme
 public void InsertCategory(Category tuple)
 {
     md.InsertIntoCategories(tuple);
 }