Esempio n. 1
0
    public void Insert(WCFBook c)
    {
        string[] idList = Data.ListBooks().ToArray <String>();
        int      newID  = 0;

        for (int i = 0; i < idList.Length; i++)
        {
            if (newID < Convert.ToInt32(idList[i]))
            {
                newID = Convert.ToInt32(idList[i]);
            }
        }
        newID = newID + 1;
        Book b = new Book
        {
            id          = newID.ToString(),
            title       = c.Title,
            description = c.Description,
            price       = c.Price,
            cg          = c.Cg,
            quantity    = c.Quantity,
            image       = c.Image
        };

        Data.InsertBook(b);
    }
Esempio n. 2
0
    public WCFBook GetBook(String id)
    {
        Book c = Data.GetBook(id);

        return(WCFBook.Make(c.id, c.title, c.description, c.price,
                            c.cg, c.image, c.quantity));
    }
Esempio n. 3
0
    public WCFBook GetBook(string id)
    {
        int  bookId = Int32.Parse(id);
        Book b      = context.Books.Where(x => x.BookID == bookId).First();

        return(WCFBook.Make(b.BookID, b.Title, b.CategoryID, b.ISBN, b.Author, b.Stock, b.Price));
    }
Esempio n. 4
0
    public WCFBook GetBook(string isbn)
    {
        Book b = Data.GetBookDetails(isbn);

        String categoryName = Data.GetCategory(b.CategoryID).CategoryName;

        return(WCFBook.Make(b.BookID, b.Title, b.ISBN, b.Author, b.Stock, b.Price, categoryName));
    }
Esempio n. 5
0
        /// <summary>
        /// Load the given file path for simple properties in sharing mode
        /// </summary>
        /// <param name="fileInfoPath"></param>
        /// <returns></returns>
        public WCFBook LoadBookInfoSimple(string fileInfoPath)
        {
            if (LogHelper.CanDebug())
            {
                LogHelper.Begin("BookInfoService.LoadBookInfoSimple");
            }
            try
            {
                //the file exist, try to load
                if (File.Exists(fileInfoPath))
                {
                    WCFBook bk = new WCFBook();

                    IFormatter formatter = new BinaryFormatter();
                    using (Stream stream = new FileStream(fileInfoPath, FileMode.Open, FileAccess.Read, FileShare.None))
                    {
                        //the thumbnail
                        using (MemoryStream coverStream = (MemoryStream)formatter.Deserialize(stream))
                        {
                            bk.Image = coverStream.GetBuffer();
                        }
                        //mySelf file to be restored
                        bk.FileInfo = (string)formatter.Deserialize(stream);
                        // comic file
                        bk.ID    = (string)formatter.Deserialize(stream);
                        bk.Title = Path.GetFileName(bk.ID);
                        //bookmark tag
                        bk.Bookmark = (string)formatter.Deserialize(stream);
                        //IsRead tag
                        bk.IsRead = (bool)formatter.Deserialize(stream);
                        //IsSecured tag
                        bk.IsSecured = (bool)formatter.Deserialize(stream);
                        //Password tag
                        bk.Password = (string)formatter.Deserialize(stream);
                        //page number
                        bk.PageCount = (int)formatter.Deserialize(stream);
                        //Size tag
                        bk.Size = (long)formatter.Deserialize(stream);
                        //Rating tag
                        bk.Rating = (int)formatter.Deserialize(stream);
                    }

                    return(bk);
                }
            }
            catch (Exception err)
            {
                LogHelper.Manage("BookInfoService.LoadBookInfoSimple", err);
            }
            finally
            {
                LogHelper.End("BookInfoService.LoadBookInfoSimple");
            }

            return(null);
        }
Esempio n. 6
0
    public List <WCFBook> List()
    {
        List <WCFBook> wlist = new List <WCFBook>();
        List <Book>    blist = BookData.ListCustomers();

        foreach (Book b in blist)
        {
            wlist.Add(WCFBook.Make(b.BookID.ToString(), b.Title, b.ISBN, b.Author, b.Stock, b.Price));
        }
        return(wlist);
    }
Esempio n. 7
0
    public void Add(WCFBook book)
    {
        Book b = new WCFHosting.Book();

        b.Author = book.Author;
        b.Title  = book.Title;
        b.ISBN   = book.Isbn;
        b.Stock  = book.Stock;
        b.Price  = book.Price;
        BookData.InsertBook(b);
    }
Esempio n. 8
0
 public WCFBook[] List()
 {
     Book[]    books    = Bookshop.Data.ListBooks().ToArray <Book>();
     WCFBook[] wcfBooks = new WCFBook[books.Length];
     for (int i = 0; i < books.Length; i++)
     {
         Book b = books[i];
         wcfBooks[i] = WCFBook.Make(b.BookID, b.Title, b.CategoryID, b.ISBN, b.Author, b.Stock, b.Price);
     }
     return(wcfBooks);
 }
Esempio n. 9
0
    public void Update(WCFBook b)
    {
        Book book = context.Books.Where(x => x.BookID == b.BookID).First();

        book.CategoryID = b.CategoryID;
        book.Author     = b.Author;
        book.ISBN       = b.ISBN;
        book.Price      = b.Price;
        book.Stock      = b.Stock;
        book.Title      = b.Title;
        context.SaveChanges();
    }
Esempio n. 10
0
    public static WCFBook Make(string id, string title, string isbn, string author, int stock, decimal price)
    {
        WCFBook b = new WCFBook();

        b.id     = id;
        b.title  = title;
        b.isbn   = isbn;
        b.author = author;
        b.stock  = stock;
        b.price  = price;
        return(b);
    }
Esempio n. 11
0
    public WCFBook[] SearchBook(string title)
    {
        List <Book> bookList = Data.GetBooksByTitle(title);

        WCFBook[] wcfBookList = new WCFBook[bookList.Count];
        for (int i = 0; i < bookList.Count; i++)
        {
            Book   b            = bookList[i];
            String categoryName = Data.GetCategory(b.CategoryID).CategoryName;
            wcfBookList[i] = WCFBook.Make(b.BookID, b.Title, b.ISBN, b.Author, b.Stock, b.Price, categoryName);
        }
        return(wcfBookList);
    }
Esempio n. 12
0
    public static WCFBook Make(int id, string title, int cat, string isbn, string author, int stock, decimal price)
    {
        WCFBook b = new WCFBook();

        b.BookID     = id;
        b.Title      = title;
        b.CategoryID = cat;
        b.ISBN       = isbn;
        b.Author     = author;
        b.Stock      = stock;
        b.Price      = price;
        return(b);
    }
Esempio n. 13
0
    public static WCFBook Make(int bookId, string title, string isbn, string author, int stock, decimal price, string category)
    {
        WCFBook b = new WCFBook();

        b.bookId   = bookId;
        b.title    = title;
        b.isbn     = isbn;
        b.author   = author;
        b.stock    = stock;
        b.price    = price;
        b.category = category;
        return(b);
    }
Esempio n. 14
0
    public void Update(WCFBook c)
    {
        Book b = new Book
        {
            BookID = Convert.ToInt32(c.Id),
            Title  = c.Title,
            Author = c.Author,
            ISBN   = c.Isbn,
            Stock  = c.Stock,
            Price  = c.Price
        };

        BookData.UpdateBook(b);
    }
Esempio n. 15
0
    public List <WCFBook> GetBookByCg(String cg)

    {
        List <WCFBook> wb = new List <WCFBook>();
        List <Book>    b  = Data.GetBookByCg(cg);

        for (int i = 0; i < b.Count; i++)
        {
            Book c = b[i];
            wb.Add(WCFBook.Make(c.id, c.title, c.description, c.price,
                                c.cg, c.image, c.quantity));
        }
        return(wb);
    }
Esempio n. 16
0
    public void Delete(WCFBook c)
    {
        Book b = new Book
        {
            id          = c.Id,
            title       = c.Title,
            description = c.Description,
            price       = c.Price,
            cg          = c.Cg,
            quantity    = c.Quantity,
            image       = c.Image
        };

        Data.DeleteBook(b);
    }
Esempio n. 17
0
    public static WCFBook Make(string id, string title, string description, double?price,
                               string cg, string image, int?quantity)
    {
        WCFBook c = new WCFBook();

        c.id          = id;
        c.title       = title;
        c.description = description;
        c.price       = price;
        c.cg          = cg;
        c.image       = image;
        c.quantity    = quantity;

        return(c);
    }
Esempio n. 18
0
    public WCFBook GetBook(string id)
    {
        Book b = BookData.GetBook(Int32.Parse(id));

        return(WCFBook.Make(b.BookID.ToString(), b.Title, b.ISBN, b.Author, b.Stock, b.Price));
    }