예제 #1
0
        public ActionResult CellList(int collectionId, string searchStr)
        {
            if (Session["admin"] != null)
            {
                ViewBag.searchStr = searchStr;

                ConfusionCate confusionCate = db.ConfusionCate.Find(collectionId);
                ViewBag.CollectionName = confusionCate.Title;
                if (!string.IsNullOrEmpty(searchStr))
                {
                    var secCate = db.ConfusionSecCate.Where(item => item.ConfusionCateId == collectionId && item.Title.Contains(searchStr)).OrderByDescending(item => item.Id);
                    return(View(secCate));
                }
                else
                {
                    var secCate = db.ConfusionSecCate.Where(item => item.ConfusionCateId == collectionId).OrderByDescending(item => item.Id);
                    return(View(secCate));
                }
            }

            else
            {
                return(RedirectToAction("Login", "Console"));
            }
        }
예제 #2
0
 public ActionResult Edit(int id)
 {
     if (Session["admin"] != null)
     {
         ViewBag.IsCreate = true;
         ConfusionCate confusionCate = db.ConfusionCate.Find(id);
         return(View("Edit", confusionCate));
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }
예제 #3
0
 public ActionResult CellEdit(int id)
 {
     if (Session["admin"] != null)
     {
         ViewBag.IsCreate = true;
         ConfusionSecCate secCate       = db.ConfusionSecCate.Find(id);
         ConfusionCate    confusionCate = db.ConfusionCate.Find(secCate.ConfusionCateId);
         ViewBag.CollectionName = confusionCate.Title;
         return(View("CellEdit", secCate));
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }
예제 #4
0
 public ActionResult CellCreate(int collectionId)
 {
     if (Session["admin"] != null)
     {
         ConfusionCate confusionCate = db.ConfusionCate.Find(collectionId);
         ViewBag.CollectionName = confusionCate.Title;
         ViewBag.IsCreate       = false;
         ConfusionSecCate secCat = new ConfusionSecCate();
         secCat.ConfusionCateId = collectionId;
         return(View("CellEdit", secCat));
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }
예제 #5
0
 public ActionResult ConfusionList(int cateId, string searchStr, int pageIndex = 1)
 {
     if (Session["admin"] != null)
     {
         ViewBag.searchStr = searchStr;
         ViewBag.LayId     = cateId;
         ConfusionSecCate secCate = db.ConfusionSecCate.Find(cateId);
         ViewBag.LayName = secCate.Title;
         ConfusionCate cate = db.ConfusionCate.Find(secCate.ConfusionCateId);
         ViewBag.BuildName = cate.Title;
         ViewBag.BuildId   = cate.Id;
         if (!string.IsNullOrEmpty(searchStr))
         {
             int iSearch = 0;
             int.TryParse(searchStr, out iSearch);
             if (iSearch != 0)
             {
                 ViewBag.pageX     = 1;
                 ViewBag.pageCount = 1;
                 var users = db.Confusions.Where(item => item.ConfusionSecId == cateId && item.Id == iSearch);
                 return(View(users));
             }
             else
             {
                 var confusions = db.Confusions.Where(item => item.ConfusionSecId == cateId && item.Title.Contains(searchStr));
                 int count      = confusions.Count();
                 confusions = confusions.OrderByDescending(item => item.Id).Skip(pageSize * (pageIndex - 1)).Take(pageSize);
                 InitPage(cateId, pageIndex, count, searchStr);
                 return(View(confusions));
             }
         }
         else
         {
             var confusions = db.Confusions.Where(item => item.ConfusionSecId == cateId).OrderByDescending(item => item.Id).Skip(pageSize * (pageIndex - 1)).Take(pageSize);;
             int count      = db.Confusions.Where(item => item.ConfusionSecId == cateId).Count();
             InitPage(cateId, pageIndex, count, searchStr);
             return(View(confusions));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }
예제 #6
0
 public ActionResult EditConfusion(int id)
 {
     if (Session["admin"] != null)
     {
         Confusions       confusion = db.Confusions.Find(id);
         ConfusionSecCate secCate   = db.ConfusionSecCate.Find(confusion.ConfusionSecId);
         ViewBag.LayId   = secCate.Id;
         ViewBag.LayName = secCate.Title;
         ConfusionCate cate = db.ConfusionCate.Find(secCate.ConfusionCateId);
         ViewBag.BuildId   = cate.Id;
         ViewBag.BuildName = cate.Title;
         ViewBag.IsCreate  = true;
         return(View(confusion));
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }
예제 #7
0
 public ActionResult SaveEdit(ConfusionCate confusionCate, bool IsCreate)
 {
     if (Session["admin"] != null)
     {
         if (IsCreate)
         {
             confusionCate.UpdateTime      = DateTime.Now;
             db.Entry(confusionCate).State = EntityState.Modified;
         }
         else
         {
             confusionCate.CreateTime = DateTime.Now;
             confusionCate.UpdateTime = DateTime.Now;
             db.ConfusionCate.Add(confusionCate);
         }
         db.SaveChanges();
         return(RedirectToAction("List"));
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }