Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request.Form["action"];
            if (action == "add")
            {
                BookShop.Model.BookComment bc = new BookShop.Model.BookComment();
                bc.BookId = Convert.ToInt32(context.Request.Form["bookId"]);
                bc.CreateDateTime = DateTime.Now;

                if (!string.IsNullOrEmpty(context.Request.Form["comment"]))
                {
                    bc.Msg = context.Request.Form["comment"];
                    if (new BookCommentBLL().Add(bc) > 0)
                    {
                        context.Response.Write("yes");
                    }
                    else
                    {
                        context.Response.Write("no");
                    }
                }
            }
            else if (action == "load")
            {
                string bookId = context.Request.Form["bookId"];
                List<BookShop.Model.BookComment> list = new BookCommentBLL().GetModelList("BookId=" + bookId, "CreateDateTime");

                List<ViewBookComment> newList = new List<ViewBookComment>();
                foreach (Model.BookComment bc in list)
                {
                    ViewBookComment vbc = new ViewBookComment();
                    vbc.CreateDateTime = Common.WebCommon.GetTimeSpanStr(DateTime.Now - bc.CreateDateTime);
                    vbc.Msg = bc.Msg;
                    newList.Add(vbc);
                }

                JavaScriptSerializer jss = new JavaScriptSerializer();
                context.Response.Write(jss.Serialize(newList));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BookShop.Model.BookComment model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(BookShop.Model.BookComment model)
 {
     return(dal.Add(model));
 }