예제 #1
0
 public JsonResult AddComment(string comment, int bookId = 0)
 {
     if (!string.IsNullOrEmpty(comment) && !string.IsNullOrWhiteSpace(comment))
     {
         BookDiscussion model = new BookDiscussion()
         {
             BookId             = bookId,
             CustomerId         = ProjectSession.CustomerId,
             MessageDescription = comment,
             IsFromAdmin        = false,
             UserId             = null,
             Approved           = true
         };
         int result = this.bookDataBL.Save(model, checkForDuplicate: false, combinationCheckRequired: false);
         if (result > 0)
         {
             return(this.Json(new { success = true, status = Infrastructure.SystemEnumList.MessageBoxType.Success.GetDescription(), message = Messages.AddComment, title = Infrastructure.SystemEnumList.Title.Book.GetDescription(), JsonRequestBehavior.DenyGet }));
         }
         else
         {
             return(this.Json(new { success = false, message = Messages.ErrorMessage.SetArguments(General.Comment), status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), title = Infrastructure.SystemEnumList.Title.Book.GetDescription() }));
         }
     }
     else
     {
         return(this.Json(new { resultData = string.Empty, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.BlankComment, title = Infrastructure.SystemEnumList.Title.Book.GetDescription(), JsonRequestBehavior.DenyGet }));
     }
 }
예제 #2
0
        public ActionResult CommentList(int?currentPage, int?bookId, int?pagesize)
        {
            List <BookDiscussion> commentList;

            BookDiscussion model = new BookDiscussion()
            {
                StartRowIndex = ((currentPage - 1) * pagesize) + 1,
                EndRowIndex   = currentPage * pagesize,
                BookId        = ConvertTo.ToInteger(bookId)
            };

            commentList = this.bookDataBL.Search <BookDiscussion>(model);

            int totalRecord = 0;

            if (commentList != null && commentList.Count > 0)
            {
                totalRecord = commentList.FirstOrDefault().TotalRecords;
            }

            if (pagesize != 1)
            {
                this.ViewBag.TotalPage = Math.Ceiling((float)totalRecord / ConvertTo.ToInteger(pagesize));
            }

            return(this.PartialView(PartialViews.CommentList, commentList));
        }