コード例 #1
0
ファイル: ClientService.svc.cs プロジェクト: svn2github/KCMS2
 public Book BookInsert(Book book)
 {
     using (DataEntities ent = new DataEntities())
     {
         ent.AddToBook(book);
         ent.SaveChanges();
         return book;
     }
 }
コード例 #2
0
ファイル: xmlrpc.aspx.cs プロジェクト: kuibono/KCMS2
        /// <summary>
        /// 添加书籍
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="Author">作者</param>
        /// <param name="ClassID">类别ID</param>
        /// <param name="Intro">简介</param>
        /// <param name="Length">长度</param>
        protected void BookAdd(string Title, string Author, int ClassID, string Intro, long Length)
        {
            string ClassName = ObjectExtents.Class(ClassID).ClassName;

            DataEntities ent=new DataEntities();

            Book b = new Book();

            if (Title.IsNullOrEmpty() && (from l in ent.Book where l.Title==Title && l.Author==Author select l).Count()>0)
            {
                b.ID = int.MinValue;
                Response.Clear();
                Response.Write(Voodoo.IO.XML.Serialize(b));
                return;
            }

            b.Addtime = DateTime.UtcNow.AddHours(8);
            b.Author = Author;
            b.ClassID = ClassID;
            b.ClassName = ClassName;
            b.ClickCount = 0;
            b.CorpusID = 0;
            b.Enable = true;
            b.FaceImage = "";
            b.Intro = Intro;
            b.IsFirstPost = false;
            b.IsVip = false;
            b.LastChapterID = 0;
            b.LastVipChapterID = 0;
            b.Length = Length;
            b.ReplyCount = 0;
            b.SaveCount = 0;
            b.Status = 0;//连载中
            b.Title = Title;
            b.UpdateTime = DateTime.UtcNow.AddHours(8);
            b.VipUpdateTime = DateTime.UtcNow.AddHours(8);
            b.ZtID = 0;

            var books = (from l in ent.Book where l.Title == Title && l.Author == Author select l).ToList();
            if (books.Count == 0)
            {
                ent.AddToBook(b);
                ent.SaveChanges();
            }
            else
            {
                b = books.FirstOrDefault();
            }
            ent.Dispose();

            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(b));
        }
コード例 #3
0
ファイル: BookEdit.aspx.cs プロジェクト: kuibono/KCMS2
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();
            var books = (from l in ent.Book where l.ID == id select l).ToList();

            Voodoo.Basement.Book book = new Voodoo.Basement.Book();
            if (books.Count > 0)
            {
                book = books.FirstOrDefault();
            }
            book.Title = txt_Title.Text;
            book.Author = txt_Author.Text;
            book.ClassID = ddl_CLass.SelectedValue.ToInt32();
            book.ClassName = ddl_CLass.SelectedItem.Text;
            book.ClickCount = txt_ClickCount.Text.ToInt32();
            book.CorpusID = 0;
            book.CorpusTitle = "";
            book.Enable = chk_Enable.Checked;
            //book.FaceImage=
            book.Intro = txt_Intro.Text;
            book.IsFirstPost = chk_IsFirstpost.Checked;
            book.IsVip = chk_IsVip.Checked;
            book.Length = txt_Length.Text.ToInt32();
            book.ReplyCount = txt_Replycount.Text.ToInt32();
            book.SaveCount = txt_SaveCount.Text.ToInt32();
            book.Status = ddl_Status.SelectedValue.ToByte();
            book.TjCount = txt_TjCount.Text.ToInt32();
            book.ZtID = 0;
            book.ZtName = "";

            if (books.Count == 0)
            {
                book.Addtime = DateTime.UtcNow.AddHours(8);
                book.UpdateTime = DateTime.UtcNow.AddHours(8);
                book.VipUpdateTime = DateTime.UtcNow.AddHours(8);
                ent.AddToBook(book);
                ent.SaveChanges();
            }

            //Deal Book face image
            if (file_Bookfacefile.FileName.IsNullOrEmpty() == false)
            {
                file_Bookfacefile.SaveAs(Server.MapPath("/Book/BookFace/" + book.ID + ".jpg"));
                book.FaceImage = "/Book/BookFace/" + book.ID + ".jpg";
                ent.SaveChanges();
            }

            CreatePage.CreateContentPage(book, book.GetClass());
            Response.Redirect("BookList.aspx?class=" + cls.ToS());
        }