Exemple #1
0
        public ActionResult UpdateNewsType(int id)
        {
            if (_user == null)
            {
                return(RedirectToAction("Login", "UserManage"));
            }
            else
            {
                meun type = _newsService.GetNewsType(id);
                ViewBag.Id         = id;
                ViewBag.TypeName   = type.Name;
                ViewBag.ParentName = _newsService.GetNewsTypeParentName(type.ParentId);
                ViewBag.ParentId   = type.ParentId;

                if (_newsService.NewsTypeExitChildren(id) == true)
                {
                    return(View());
                }
                else
                {
                    List <NewsTypeViewModel> model = (from m in _ctx.meun
                                                      where m.IsDelete == false && m.ParentId == null
                                                      select new NewsTypeViewModel
                    {
                        Id = m.Id,
                        Name = m.Name
                    }).ToList();
                    return(View(model));
                }
            }
        }
Exemple #2
0
        public meun DeleteNewsType(int id)
        {
            meun m = _ctx.meun.SingleOrDefault(c => c.Id == id);

            m.IsDelete = true;
            _ctx.SaveChanges();
            return(m);
        }
Exemple #3
0
        public bool NewsTypeExitChildren(int id)
        {
            meun type = _ctx.meun.Find(id);

            if (type.ParentId == null)
            {
                var list = _ctx.meun.Where(m => m.ParentId == id);
                if (list == null)
                {
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Exemple #4
0
 public meun UpdateNewsType(int id, Nullable <int> parentId, string newType)
 {
     try
     {
         meun m = _ctx.meun.SingleOrDefault(c => c.Id == id);
         m.Name     = newType;
         m.ParentId = parentId;
         _ctx.SaveChanges();
         return(m);
     }
     catch
     {
         throw new Exception("添加失败");
     }
 }
Exemple #5
0
        public meun AddNewsType(string newsType, Nullable <int> parentId)
        {
            meun list = _ctx.meun.SingleOrDefault(m => m.Name == newsType && m.ParentId == parentId);

            if (list == null)
            {
                meun m = new meun()
                {
                    Name     = newsType,
                    ParentId = parentId,
                    IsDelete = false
                };
                _ctx.meun.Add(m);
                _ctx.SaveChanges();
                return(m);
            }
            throw new Exception();
        }
Exemple #6
0
        public ActionResult UpdateNewsType(int id, Nullable <int> parentId, string typeName)
        {
            if (_user == null)
            {
                return(RedirectToAction("Login", "UserManage"));
            }
            else
            {
                try
                {
                    meun m = _newsService.UpdateNewsType(id, parentId, typeName);
                    return(Json("修改成功", JsonRequestBehavior.AllowGet));
                }

                catch
                {
                    return(Json("修改失败", JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemple #7
0
        public ActionResult DeleteNewType(int id)
        {
            meun m = _newsService.DeleteNewsType(id);

            return(RedirectToAction("GetAllNewsType", "NewsManage"));
        }