Esempio n. 1
0
        public ActionResult AddToCart(int uniqueId)
        {
            SingleBook    singlebook          = new SingleBook();
            CSBook        CStargetBook        = null;
            EconomicsBook EconomicstargetBook = null;
            NovelBook     NoveltargetBook     = null;

            using (Group001BookstoreEntities dbContext = new Group001BookstoreEntities())
            {
                if (uniqueId < 2000)
                {
                    CStargetBook      = dbContext.CSBooks.SingleOrDefault(n => n.UniqueId == uniqueId);
                    singlebook.CSBook = CStargetBook;
                }
                else if (uniqueId > 2000 & uniqueId < 3000)
                {
                    EconomicstargetBook      = dbContext.EconomicsBooks.SingleOrDefault(n => n.UniqueId == uniqueId);
                    singlebook.Economicsbook = EconomicstargetBook;
                }
                else
                {
                    NoveltargetBook      = dbContext.NovelBooks.SingleOrDefault(n => n.UniqueId == uniqueId);
                    singlebook.NovelBook = NoveltargetBook;
                }
            }

            return(View("OrderReview", singlebook));
        }
Esempio n. 2
0
        public ActionResult Detail(int uniqueId)
        {
            CSBook targetBook = null;

            using (Group001BookstoreEntities dbContext = new Group001BookstoreEntities())
            {
                targetBook = dbContext.CSBooks.SingleOrDefault(b => b.UniqueId == uniqueId);
            }
            return(View(targetBook));
        }
Esempio n. 3
0
        public ActionResult Detail(CSBook book)
        {
            using (Group001BookstoreEntities dbContext = new Group001BookstoreEntities())
            {
                if (this.Request.Files != null && this.Request.Files.Count > 0 && this.Request.Files[0].ContentLength > 0 && this.Request.Files[0].ContentLength < 1024 * 1024)
                {
                    string fileName      = Path.GetFileName(this.Request.Files[0].FileName);
                    string pathOfWebsite = "~/Images/CSBookCovers/" + fileName;
                    book.CoverImagePath = pathOfWebsite;
                    this.Request.Files[0].SaveAs(this.Server.MapPath(pathOfWebsite));
                }

                dbContext.CSBooks.Attach(book);
                dbContext.Entry(book).State = System.Data.Entity.EntityState.Modified;
                dbContext.SaveChanges();
            }
            return(RedirectToAction("Show"));
        }