public ActionResult GetTypeByBelonger(TypeBelonger belonger)
 {
     List<TypeDictionary> TypeDictionaries = new List<TypeDictionary>();
     TypeDictionaries = db.TypeDictionaries.Where(td => td.Belonger == belonger && td.FatherID == 0).ToList();
     return Json(TypeDictionaries, JsonRequestBehavior.AllowGet);
 }
 public ActionResult AddType(TypeBelonger Belonger, string TypeValue, int NeedAuthorize, int FatherID)
 {
     bool flag = Convert.ToBoolean(NeedAuthorize);
     TypeDictionary type = new TypeDictionary { TypeValue = TypeValue, Belonger = Belonger, NeedAuthorize = flag, FatherID = FatherID, Time = DateTime.Now };
     db.TypeDictionaries.Add(type);
     db.SaveChanges();
     return RedirectToAction("TypeManager");
 }
 public ActionResult AddType(TypeBelonger type)
 {
     List<TypeDictionary> list = db.TypeDictionaries.Where(tp => tp.Belonger == type && tp.FatherID == 0).ToList();
     ViewBag.LastTypes = list;
     ViewBag.Type = type;
     return View();
 }
 public ActionResult AddType(TypeBelonger Belonger, string TypeValue, int NeedAuthorize, int FatherID, int? PID, int Top)
 {
     TypeDictionary temp = db.TypeDictionaries.Where(tp => tp.TypeValue == TypeValue.Trim() && tp.Belonger == Belonger).FirstOrDefault();
     if (temp != null)
     {
         return Redirect("/Admin/AdminMessage?msg=你填写的分类名称已经存在!");
     }
     bool flag = Convert.ToBoolean(NeedAuthorize);
     bool top = Convert.ToBoolean(Top);
     TypeDictionary type = new TypeDictionary { TypeValue = TypeValue, Belonger = Belonger, NeedAuthorize = flag, FatherID = FatherID, Time = DateTime.Now, PID = PID, Top = top };
     db.TypeDictionaries.Add(type);
     db.SaveChanges();
     return Redirect("/Admin/TypeManager?type=" + Belonger);
 }
        public ActionResult TypeManager(string key, DateTime? Begin, DateTime? End, TypeBelonger type, int p = 0)
        {
            IEnumerable<TypeDictionary> query = db.TypeDictionaries.Where(tp => tp.Belonger == type);
            if (!string.IsNullOrEmpty(key))
            {
                query = query.Where(c => c.TypeValue.Contains(key));
            }
            if (Begin.HasValue)
            {
                query = query.Where(c => c.Time >= Begin);
            }
            if (End.HasValue)
            {
                query = query.Where(c => c.Time <= End);
            }

            query = query.OrderByDescending(x => x.Time);
            ViewBag.PageInfo = PagerHelper.Do(ref query, 20, p);
            ViewBag.Type = type;
            return View(query);
        }