Esempio n. 1
0
        public ActionResult Comment(BookComment comment, int CommentBookID, string Comment_Content)
        {
            #region
            BooksDetails a = new BooksDetails(CommentBookID);
            int          UserID;
            var          UserComment = a.Bc;
            ViewBag.Comment = UserComment;
            UserID          = Convert.ToInt32(Session["User_id"]);
            //string textarea = Request["Comment_Content"];
            if (ModelState.IsValid)
            {
                if (Comment_Content != "")
                {
                    comment.UserID          = UserID;
                    comment.BookID          = CommentBookID;
                    comment.Comment_Content = Comment_Content;
                    comment.Comment_Time    = System.DateTime.Now;
                    imall.AddComment(comment);
                    UserComment     = a.Bc;
                    ViewBag.Comment = UserComment;
                    return(PartialView(ViewBag.Comment as IEnumerable <BookComment>));
                }
                else
                {
                    return(PartialView(ViewBag.Comment as IEnumerable <BookComment>));
                }
            }
            return(PartialView(ViewBag.Comment as IEnumerable <BookComment>));

            #endregion
        }
Esempio n. 2
0
 public IActionResult AddBooks(BooksDetails BookName)
 {
     Books.Add(new BooksDetails()
     {
         Name = BookName.Name, Quantity = BookName.Quantity
     });
     return(View("index", Books));
 }
Esempio n. 3
0
        public IActionResult BorrowBooks(BooksDetails Book)
        {
            foreach (var item in Books)
            {
                if (item.Name == Book.Name)
                {
                    item.Quantity = item.Quantity - Book.Quantity;
                }
                //foreach (var quant in Books)
                //  if (item.Quantity == 0)
                Books.Remove(Books.Single(x => x.Quantity == 0));
                return(View("index", Books));

                //if(item.Quantity==0)
                //{
                //    Books.Remove(item.Name);
                //}
            }
            return(View("index", Books));
        }