public void DeleteBookSoftCopy(int?bSCID)
        {
            BOOK_SOFTCOPY bookSoftCopy = dataAccess.BOOK_SOFTCOPies.Single(bSoftCopy => bSoftCopy.BSCID == bSCID);

            dataAccess.BOOK_SOFTCOPies.DeleteOnSubmit(bookSoftCopy);
            dataAccess.SaveChanges();
        }
        public void UpdateBookSoftCopy(BOOK_SOFTCOPY bSoftCopy)
        {
            BOOK_SOFTCOPY bookSoftCopy = dataAccess.BOOK_SOFTCOPies.Single(bSC => bSC.BSCID == bSoftCopy.BSCID);

            bookSoftCopy = bSoftCopy;
            dataAccess.SaveChanges();
        }
Beispiel #3
0
        public ActionResult AddBook(BOOK book, List <int> Authors, List <int> Categories,
                                    List <HttpPostedFileBase> bookImages, List <HttpPostedFileBase> bookSoftCopy)
        {
            try
            {
                book.CREATED_DATE = DateTime.Now;
                book = BookModel.AddBook(book);

                foreach (int aID in Authors)
                {
                    BOOK_AUTHOR bookAuthor = new BOOK_AUTHOR();
                    bookAuthor.BOOKID   = book.BOOKID;
                    bookAuthor.AUTHORID = aID;
                    AuthorModel.AddBookAuthor(bookAuthor);
                }

                foreach (int bCID in Categories)
                {
                    BOOK_CATEGORY bookCat = new BOOK_CATEGORY();
                    bookCat.BOOKID     = book.BOOKID;
                    bookCat.CATEGORYID = bCID;
                    CategoryModel.AddBookCategory(bookCat);
                }

                foreach (HttpPostedFileBase image in bookImages)
                {
                    String     fname     = Generator.RandomString(10) + "." + image.FileName.Split('.')[image.FileName.Split('.').Length - 1];
                    string     path      = Server.MapPath("~/UserImages/") + fname;
                    BOOK_IMAGE bookImage = new BOOK_IMAGE();
                    bookImage.BOOKID    = book.BOOKID;
                    bookImage.IMAGEPATH = "/UserImages/" + fname;
                    image.SaveAs(path);
                    BookModel.AddBookImage(bookImage);
                }
                if (bookSoftCopy != null)
                {
                    foreach (HttpPostedFileBase bookSC in bookSoftCopy)
                    {
                        String        fname = Generator.RandomString(10) + "." + bookSC.FileName.Split('.')[bookSC.FileName.Split('.').Length - 1];
                        string        path  = Server.MapPath("~/UserImages/") + fname;
                        BOOK_SOFTCOPY bSC   = new BOOK_SOFTCOPY();
                        bSC.BOOKID   = book.BOOKID;
                        bSC.FILEPATH = "/UserImages/" + fname;
                        bSC.FILESIZE = bookSC.ContentLength;
                        bookSC.SaveAs(path);
                        BookModel.AddBookSoftCopy(bSC);
                    }
                }
                ViewBag.Message = SuccessMessage.BOOK_ADDED;
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message;
            }

            initialiseViewBag();
            return(View(book));
        }
 public void InsertBookSoftCopy(BOOK_SOFTCOPY copy)
 {
     dataAccess.BOOK_SOFTCOPies.InsertOnSubmit(copy);
     dataAccess.SaveChanges();
 }
Beispiel #5
0
 internal static void AddBookSoftCopy(BOOK_SOFTCOPY bSC)
 {
     Service.InsertBookSoftCopy(bSC);
 }