public void UpdateBookAuthor(BOOK_AUTHOR bAuthor)
        {
            BOOK_AUTHOR bookAuthor = dataAccess.BOOK_AUTHORs.Single(ba => ba.AUTHORID == bAuthor.AUTHORID);

            bookAuthor = bAuthor;
            dataAccess.SaveChanges();
        }
        public void DeleteBookAuthor(int bAuthorID)
        {
            BOOK_AUTHOR bookAuthor = dataAccess.BOOK_AUTHORs.First(bAuthor => bAuthor.BOOK_AUTHORID == bAuthorID);

            dataAccess.BOOK_AUTHORs.DeleteOnSubmit(bookAuthor);
            dataAccess.SaveChanges();
        }
Exemple #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 InsertBookAuthor(BOOK_AUTHOR author)
 {
     dataAccess.BOOK_AUTHORs.InsertOnSubmit(author);
     dataAccess.SaveChanges();
 }
Exemple #5
0
 internal static void AddBookAuthor(BOOK_AUTHOR bookAuthor)
 {
     localhost.InsertBookAuthor(bookAuthor);
 }
Exemple #6
0
        internal static void DeleteBookAuthor(int aUTHORID, int bOOKID)
        {
            BOOK_AUTHOR bAuthor = localhost.GetBookAuthors().Single(bA => bA.AUTHORID == aUTHORID && bA.BOOKID == bOOKID);

            localhost.DeleteBookAuthor(bAuthor.BOOK_AUTHORID);
        }
Exemple #7
0
 internal static void AddAuthor(BOOK_AUTHOR bookAuthor)
 {
     throw new NotImplementedException();
 }