예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ClassName=WS.RequestString("class");
            int Model=WS.RequestInt("m",4);
            if (ClassName.Length == 0)
            {
                return;
            }

            Class cls = ClassAction.Classes.Where(p => p.ClassName == ClassName && p.ModelID == Model).FirstOrDefault();
            if (cls.ID <= 0)
            {
                //cls.ClassForder = PinyinHelper.GetPinyin(ClassName);
                cls.ClassForder = ClassName;
                cls.ClassKeywords = ClassName;
                cls.ClassName = ClassName;
                cls.ModelID = Model;
                cls.IsLeafClass = true;
                cls.ModelID = Model;
                cls.ShowInNav = true;
                using (DataEntities ent = new DataEntities())
                {
                    ent.AddToClass(cls);
                    ent.SaveChanges();
                    Voodoo.Cache.Cache.Clear("_NewClassList");
                }
            }
            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(cls));
        }
예제 #2
0
 public Class ClassInsert(Class cls)
 {
     using (DataEntities ent = new DataEntities())
     {
         ent.AddToClass(cls);
         ent.SaveChanges();
         return cls;
     }
 }
예제 #3
0
        /// <summary>
        /// 获取栏目
        /// </summary>
        /// <param name="ClassName">栏目名称</param>
        /// <param name="ModelID">模型 1新闻 2图片 3问答 4小说</param>
        protected void GetClass(string ClassName, int ModelID)
        {
            DataEntities ent = new DataEntities();
            Class cls = (from l in ent.Class where l.ModelID == ModelID && l.ClassName == ClassName select l).FirstOrDefault();
            if (cls.ID <= 0)
            {
                //cls.ClassForder = PinyinHelper.GetPinyin(ClassName);
                cls.ClassForder = ClassName;
                cls.ClassKeywords = ClassName;
                cls.ClassName = ClassName;
                cls.ModelID = ModelID;
                cls.IsLeafClass = true;
                cls.ModelID = ModelID;
                cls.ShowInNav = true;
                ent.AddToClass(cls);

            }
            ent.SaveChanges();
            ent.Dispose();

            Voodoo.Cache.Cache.Clear("_NewClassList");

            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(cls));
        }