public ActionResult Edit(tb_Menus entity)
 {
     if (ModelState.IsValid)
     {
         entity.Order  = entity.Order ?? 0;
         entity.Status = entity.Status ?? true;
         Dao.Update(entity);
     }
     ViewBag.TypeId   = new SelectList(Dao.ListAllType(), "Id", "Name", entity.TypeId);
     ViewBag.ParentId = new SelectList(Dao.ListAll(), "Id", "Text", entity.ParentId);
     return(View(entity));
 }
Exemple #2
0
 public bool Update(tb_Menus entity)
 {
     try
     {
         db.Entry(entity).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public ActionResult Add(tb_Menus entity)
 {
     if (ModelState.IsValid)
     {
         entity.Order  = entity.Order ?? 0;
         entity.Status = entity.Status ?? true;
         long Id = Dao.Insert(entity);
         return(RedirectToAction("Edit", "Menus", new { Id = Id }));
     }
     ViewBag.TypeId   = new SelectList(Dao.ListAllType(), "Id", "Name", entity.TypeId);
     ViewBag.ParentId = new SelectList(Dao.ListAll(), "Id", "Text", entity.ParentId);
     return(View(entity));
 }
Exemple #4
0
 public long Insert(tb_Menus entity)
 {
     db.tb_Menus.Add(entity);
     db.SaveChanges();
     return(entity.Id);
 }