Beispiel #1
0
 public bool CourseAdd(Entities db, string name, State state, int ordinal, bool range)
 {
     try
     {
         var course = new Catalog
         {
             Id = db.GetId(),
             ParentId = HomoryCoreConstant.CourseOtherId,
             TopId = range ? Guid.Empty : (Guid?)null,
             Name = name,
             State = state,
             Ordinal = ordinal,
             Type = CatalogType.课程
         };
         var ex = db.Catalog.SingleOrDefault(o => o.Name == name && o.Type == CatalogType.课程);
         if (ex == null)
         {
             db.Catalog.Add(course);
             db.SaveChanges();
         }
         else
         {
             ex.State = state;
             ex.Ordinal = ordinal;
             db.SaveChanges();
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #2
0
 protected string CountChildren(Catalog catalog)
 {
     if (catalog.Id == Guid.Empty)
     {
         var count = HomoryContext.Value.Catalog.Count(o => o.State < State.删除 && o.Type == CatalogType.课程资源);
         return count == 0 ? string.Empty : string.Format(" [{0}]", count);
     }
     else
     {
         var count = catalog.CatalogChildren.Count(o => o.State < State.删除 && o.Type == CatalogType.课程资源);
         return count == 0 ? string.Empty : string.Format(" [{0}]", count);
     }
 }
Beispiel #3
0
 protected string CountChildren(Catalog catalog)
 {
     if (catalog.Id == Guid.Empty)
     {
         var count = HomoryContext.Value.Catalog.Count(o => o.State < State.删除 && o.Type == CatalogType.文章 && (o.ParentId == null || (o.ParentId != null && o.ParentId == ArticleTopId)));
         return count == 0 ? string.Empty : string.Format(" [{0}]", count);
     }
     else
     {
         var count = catalog.CatalogChildren.Count(o => o.State < State.删除 && o.Type == CatalogType.文章);
         return count == 0 ? string.Empty : string.Format(" [{0}]", count);
     }
 }
Beispiel #4
0
 protected string Iconed(Catalog course)
 {
     var id = Guid.Parse(tree.SelectedNode.Value);
     var count = course.Learned.Count(o => o.State == State.启用 && o.DepartmentId == id);
     return string.Format("{0} {1}", count == 0 ? "×" : "√", course.Name);
 }
Beispiel #5
0
 protected string HandleButton(Catalog course)
 {
     var id = Guid.Parse(tree.SelectedNode.Value);
     return course.Learned.Count(o => o.State == State.启用 && o.DepartmentId == id) == 0 ? "btn btn-primary" : "btn btn-info";
 }
Beispiel #6
0
 protected string CountChildren(Catalog catalog)
 {
     var count = catalog.CatalogChildren.Count(o => o.State == State.启用 && o.Type == CatalogType.团队_教研);
     return count == 0 ? string.Empty : string.Format(" [{0}]", count);
 }
Beispiel #7
0
        private void LoadInit()
        {
            loading.InitialDelayTime = int.Parse("Busy".FromWebConfig());

            Guid newId = Guid.Parse(Request.QueryString[0]);
            if (HomoryContext.Value.Catalog.Count(o => o.Id == newId) == 0)
            {
                var root = new Catalog
                {
                    Id = newId,
                    Name = string.Format("{0}栏目", "教研团队"),
                    Ordinal = 0,
                    ParentId = null,
                    TopId = newId,
                    State = State.启用,
                    Type = CatalogType.团队_教研
                };
                HomoryContext.Value.Catalog.AddOrUpdate(root);
                HomoryContext.Value.SaveChanges();
            }

            BindTree();
            InitTree();
        }