Ejemplo n.º 1
0
        public ActionResult Create(BookUp data)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    Book book = new Book();
                    book.Author = data.Author;
                    book.Category = data.Category;
                    book.Publish = data.Publish;
                    book.Price = data.Price;
                    book.OldLevel = data.OldLevel;
                    book.Name = data.Name;
                    book.UserID = Convert.ToInt32(Session["Uid"]);
                    book.TotalNum = Convert.ToInt32(data.TotalNum);
                    book.Categories = data.Categories;
                    book.BookState="true";
                    Usedb.Book.Add(book);
                    Usedb.SaveChanges();
                    int a = 0;

                    return RedirectToAction("Index");
                }
                else
                    return View(data);

            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 2
0
        public ActionResult BookUpload(BookUp data)
        {
            if (ModelState.IsValid)
                {
                    Book book = new Book();
                    book.Author = data.Author;
                    book.Category = data.Category;
                    book.Publish = data.Publish;
                    book.Price = data.Price;
                    book.OldLevel = data.OldLevel;
                    book.Name = data.Name;
                    book.UserID = Convert.ToInt32(Session["Uid"]);
                    book.TotalNum = Convert.ToInt32(data.TotalNum);
                    book.Categories = data.Categories;
                    Usedb.Book.Add(book);
                    Usedb.SaveChanges();
                    TempData["bookupload"] = "上传成功!";
                }

            return View("BookUpload");
        }
Ejemplo n.º 3
0
        public ActionResult Edit(Book book)
        {
            if (ModelState.IsValid)
            {
                Usedb.Entry(book).State = EntityState.Modified;
                Usedb.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(book);
        }