public void DeleteBookLetSales(int?id)
        {
            //make book avaliable then delete sale
            BookLetSales bookSale = db.BookLetSales.Find(id);
            BookLetTable book     = db.BookLet.Find(bookSale.BookLetId);

            db.Entry(book).State = EntityState.Modified;
            book.Status          = 0;

            db.BookLetSales.Remove(bookSale);
            db.SaveChanges();
        }
        public void SaleBook(BookLetSalesViewModel model)
        {
            BookLetSales book = new BookLetSales {
                Date = model.Date, BookLetId = model.BookLetId, CustomerId = model.CustomerId, CustomerName = model.CustomerName
            };

            db.BookLetSales.Add(book);
            db.SaveChanges();
            BookLetTable oldBook = db.BookLet.Find(model.BookLetId);

            db.Entry(oldBook).State = EntityState.Modified;
            oldBook.Status          = 1;
            db.SaveChanges();
        }
        public void UpdateBookLetSale(BookLetSalesViewModel model)
        {
            BookLetSales bookSale = db.BookLetSales.Find(model.Serial);
            BookLetTable oldbook  = db.BookLet.Find(bookSale.BookLetId);

            db.Entry(oldbook).State = EntityState.Modified;
            oldbook.Status          = 0;

            db.Entry(bookSale).State = EntityState.Modified;
            bookSale.Date            = model.Date;
            bookSale.BookLetId       = model.BookLetId;
            bookSale.CustomerId      = model.CustomerId;
            bookSale.CustomerName    = model.CustomerName;

            BookLetTable newbook = db.BookLet.Find(model.BookLetId);

            db.Entry(newbook).State = EntityState.Modified;
            newbook.Status          = 1;

            db.SaveChanges();
        }