示例#1
0
 public static bool UpdateCategory(DBO.Category category)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Category t_category = bdd.T_Category.Where(x => x.id == category.Id).FirstOrDefault();
             if (t_category != null)
             {
                 t_category.id   = category.Id;
                 t_category.name = category.Name;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "Id,Name")] DBO.Category category)
 {
     if (ModelState.IsValid)
     {
         //Generated : db.Entry(category).State = EntityState.Modified;
         BusinessManagement.Category.UpdateCategory(category);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
示例#3
0
        public ActionResult Create([Bind(Include = "Id,Name")] DBO.Category category)
        {
            if (ModelState.IsValid)
            {
                //Generated : db.Categories.Add(category);
                BusinessManagement.Category.CreateCategory(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
示例#4
0
        // GET: Categories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //Generated : Category category = db.Categories.Find(id);
            DBO.Category category = BusinessManagement.Category.GetCategory((int)id);

            if (category == null)
            {
                return(HttpNotFound());
            }
            return(View(category));
        }
示例#5
0
 public static bool CreateCategory(DBO.Category category)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Category t_category = new T_Category()
             {
                 id   = category.Id,
                 name = category.Name
             };
             bdd.T_Category.Add(t_category);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
示例#6
0
 public static bool CreateCategory(DBO.Category category)
 {
     return(DataAccess.Category.CreateCategory(category));
 }