public static bool addCate(ModelView.Category item) { db = new ShopOnlineEntities(); Category cate = new Category { name = item.name, StatusCat = 1 }; db.Categories.Add(cate); return(db.SaveChanges() > 0); }
public static bool updateCate(ModelView.Category item) { try { Category cate = db.Categories.Find(item.ID) as Category; cate.name = item.name; cate.StatusCat = 1; db.SaveChanges(); return(true); } catch (Exception ex) { return(false); throw ex; } }