Esempio n. 1
0
        public ActionResult Create(Book book, HttpPostedFileBase uploadimage)
        {
            string filePath = "";

            if (uploadimage.ContentLength > 0)
            {
                string fileName = Guid.NewGuid().ToString() + " " + uploadimage.FileName;
                filePath = Path.Combine(HttpContext.Server.MapPath("~/Content/Image"), fileName);
                uploadimage.SaveAs(filePath);
                book.CoverImage = fileName;
            }
            using (BooksDAL svBooks = new BooksDAL())
            {
                try
                {
                    svBooks.Add(book);
                    TempData["Pesan"] = Helper.KotakPesan.GetPesan("success",
                                                                   "Sukses ", "Data berhasil ditambahkan");
                }
                catch (Exception ex)
                {
                    TempData["Pesan"] = Helper.KotakPesan.GetPesan("danger",
                                                                   "Error! ", ex.Message);
                }
            }
            return(RedirectToAction("Index"));
        }
        static void Main(string[] args)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load("../../complex-books.xml");
            string xPathQuery = "/catalog/book";

            XmlNodeList booksList = xmlDoc.SelectNodes(xPathQuery);

            foreach (XmlNode bookNode in booksList)
            {
                string title      = bookNode.GetObligatoryChildText("title");
                string isbnString = bookNode.GetChildText("isbn");
                long?  isbn       = null;
                if (isbnString != null)
                {
                    isbn = long.Parse(isbnString);
                }

                string  priceString = bookNode.GetChildText("price");
                decimal?price       = null;
                if (priceString != null)
                {
                    price = decimal.Parse(priceString);
                }

                string webSite = bookNode.GetChildText("web-site");

                List <string> authorNames = GetAuthors(bookNode, "authors/author");

                List <ReviewData> reviews = GerReviews(bookNode, "reviews/review");

                BooksDAL.AddBook(title, isbn, price, webSite, authorNames, reviews);
            }
        }
Esempio n. 3
0
        public void TestGetBookByID1()
        {
            int      ID_Book = -1000;
            BooksDAL bo      = new BooksDAL();

            Assert.Null(bo.GetBookById(ID_Book));
        }
Esempio n. 4
0
 public ActionResult Search(string selectKriteria, string txtSearch)
 {
     using (BooksDAL svBooks = new BooksDAL())
     {
         var results = svBooks.SearchByKriteria(selectKriteria, txtSearch).ToList();
         return(View("ViewAllBooks", results));
     }
 }
 // GET: Books
 public ActionResult Index()
 {
     using (BooksDAL svBooks = new BooksDAL())
     {
         var results = svBooks.GetData();
         return(View(results));
     }
 }
Esempio n. 6
0
 public ActionResult ViewAllBooks()
 {
     using (BooksDAL svBooks = new BooksDAL())
     {
         var results = svBooks.GetBooksWithAuthors().ToList();
         return(View(results));
     }
 }
Esempio n. 7
0
 public ActionResult Details(int id)
 {
     using (BooksDAL svBooks = new BooksDAL())
     {
         var result = svBooks.GetDetailWithAuthors(id);
         return(View(result));
     }
 }
Esempio n. 8
0
        public ActionResult Book(Books b)
        {
            int      i    = 0;
            BooksDAL bdal = new BooksDAL();

            bdal.SaveBooks(false, b);
            return(View(b));
        }
Esempio n. 9
0
 public IHttpActionResult GetFinderBooks(BooksEntities booksEntities)
 {
     using (DBNexosBook db = new DBNexosBook())
     {
         var a = BooksDAL.FinderBook(db, booksEntities);
         booksEntities = a.FirstOrDefault();
     }
     return(Ok(booksEntities));
 }
        public ActionResult Book(Books b)
        {
            int      i          = 0;
            BooksDAL bdal       = new BooksDAL();
            bool     isEditMode = bdal.GetBook().Where(bk => bk.Code == b.Code).Count() == 0 ?false : true;

            bdal.SaveBooks(isEditMode, b);
            return(RedirectToAction("Book", new { Code = b.Code }));
        }
        public void GetBook()
        {
            List <Libaray.BusinessObjects.Books> bs = new BooksDAL().GetBook();
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Clear();
            Context.Response.ContentType = "json;";
            var data = js.Serialize(bs);

            Context.Response.Write(data);
        }
Esempio n. 12
0
 // GET: Books
 public ActionResult Index()
 {
     using (BooksDAL svBooks = new BooksDAL())
     {
         if (TempData["Pesan"] != null)
         {
             ViewBag.Pesan = TempData["Pesan"].ToString();
         }
         var results = svBooks.GetData().ToList();
         return(View(results));
     }
 }
Esempio n. 13
0
        private void InitializeDatabase()
        {
            Book root = new Book();
            root.NodeID = Guid.NewGuid().ToString();
            root.NodeName = "Root";
            root.BookType = "Root";

            _databaseBooks = new BooksDAL();
            _databaseBooks.AddSubNode("", root);

            BindingDBTree();
        }
Esempio n. 14
0
        //
        // GET: /Library/

        public ActionResult Book(int?Code)
        {
            Books b = new Books();

            if (!Code.HasValue)
            {
                b.Code = new BooksDAL().GetNextCode();
            }
            else
            {
                b = new BooksDAL().GetBook().Where(bk => bk.Code == Code.Value).First <Books>();
            }
            b.BookList = new BooksDAL().GetBook();
            return(View(b));
        }
Esempio n. 15
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        bool done = BooksDAL.AddReview(
            Int32.Parse(Request.QueryString["bookid"]),
            Int32.Parse(Session["userid"].ToString()),
            Int32.Parse(ddlRating.SelectedItem.Value),
            txtReview.Text);

        if (done)
        {
            lblMsg.Text = "Your review has been added sucessfully!";
        }
        else
        {
            lblMsg.Text = "Sorry! Could not add your review. Please try again!";
        }
    }
Esempio n. 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Book b = BooksDAL.GetBook(Int32.Parse(Request.QueryString["bookid"]));

        fvBook.DataSource = new Book [] { b };
        fvBook.DataBind();

        if (b.Reviews == null || b.Reviews.Count() == 0)
        {
            dlReviews.Visible = false;
        }
        else
        {
            dlReviews.DataSource = b.Reviews;
            dlReviews.DataBind();
            dlReviews.Visible = true;
        }
    }
Esempio n. 17
0
        public string PostBooks(BooksEntities books)
        {
            string response;

            try
            {
                using (DBNexosBook db = new DBNexosBook())
                {
                    response = BooksDAL.AddBook(db, books);
                }
            }
            catch (Exception)
            {
                return("No se pudo hacer el registro, consulte a su administrador");

                throw;
            }
            return(response);
        }
Esempio n. 18
0
 public void Load_Books(Subject[] subjects, string[] topicsNames)
 {
     //int count = 0;
     for (int i = 0; i < subjects.Count(); i++)
     {
         BooksDAL  b  = new BooksDAL();
         DataTable dt = b.Load_Subject(topicsNames[i]);
         subjects[i]      = new Subject(dt.Rows.Count);
         subjects[i].Name = topicsNames[i];
         if (dt.Rows.Count > 0)
         {
             //topics[i] = new Topic(dt.Rows.Count);
             for (int j = 0; j < dt.Rows.Count; j++)
             {
                 subjects[i].Books[j] = new Book(dt.Rows[j][1].ToString(), dt.Rows[j][4].ToString(),
                                                 (int)dt.Rows[j][2], dt.Rows[j][3].ToString(), (int)dt.Rows[j][5]);
             }
             //count++;
         }
     }
 }
Esempio n. 19
0
        private static void ProcessSearchQueries(XmlTextWriter writer)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load("../../reviews-queries.xml");
            string xPathQuery = "/review-queries/query";

            XmlNodeList queriesList = xmlDoc.SelectNodes(xPathQuery);

            foreach (XmlNode queryNode in queriesList)
            {
                var queryType = queryNode.Attributes["type"].InnerText;

                IList <ReviewComplexData> reviews;
                if (queryType == "by-period")
                {
                    string startDateString = GetChildText(queryNode, "start-date");
                    string endDateString   = GetChildText(queryNode, "end-date");

                    CultureInfo provider  = CultureInfo.InvariantCulture;
                    DateTime    startDate = DateTime.ParseExact(startDateString, "d-MMM-yyyy", provider);
                    DateTime    endDate   = DateTime.ParseExact(endDateString, "d-MMM-yyyy", provider);

                    reviews = BooksDAL.FindReviewsByPeriod(startDate, endDate);
                }
                else
                {
                    string authorName = GetChildText(queryNode, "author-name");

                    reviews = BooksDAL.FindReviewsByAuthorName(authorName);
                }

                WriteReviews(writer, reviews);

                //BooksDAL.WriteQueryInLog(queryNode.OuterXml);

                /* USING CODE FIRST */
                SearchLogDAL.WriteQueryInLog(queryNode.OuterXml);
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load("../../simple-query.xml");

            XmlNode query = xmlDoc.SelectSingleNode("/query");

            string title      = GetChildText(query, "title");
            string author     = GetChildText(query, "author");
            string isbnString = GetChildText(query, "isbn");
            long?  isbn       = null;

            if (isbnString != null)
            {
                isbn = long.Parse(isbnString);
            }

            List <BookReviewsData> booksReviewsData = BooksDAL.FindBooksAndGetReviews(title, author, isbn);

            if (booksReviewsData.Count == 0)
            {
                Console.WriteLine("Nothing found");
            }
            else
            {
                foreach (BookReviewsData bookData in booksReviewsData)
                {
                    string reviewsCount = "Nothing found";
                    if (bookData.ReviewsCount > 0)
                    {
                        reviewsCount = bookData.ReviewsCount.ToString();
                    }

                    Console.WriteLine("{0} --> {1}", bookData.Title, reviewsCount);
                }
            }
        }
Esempio n. 21
0
        public void Loan_Book(Book book, string Username)
        {
            BooksDAL b = new BooksDAL();

            b.Loan_Book(book.Name, Username);
        }
Esempio n. 22
0
 /// <summary>
 /// 查询书本以及类型根据条形码
 /// </summary>
 /// <param name="BarCode"></param>
 /// <returns></returns>
 public static DataTable SelectBooksTypeByBarCode(string BarCode)
 {
     return(BooksDAL.selectbookstypeBarCode(BarCode));
 }
Esempio n. 23
0
 /// <summary>
 /// 根据书本名模糊查询
 /// </summary>
 /// <param name="BooksName"></param>
 /// <returns></returns>
 public static DataTable GetBooksLikeName(string BooksName)
 {
     return(BooksDAL.GetBooksLikeName(BooksName));
 }
Esempio n. 24
0
 /// <summary>
 /// 添加书本
 /// </summary>
 /// <param name="gs"></param>
 /// <returns></returns>
 public static bool InsertBooks(Books gs)
 {
     return(BooksDAL.InsertBooks(gs));
 }
Esempio n. 25
0
 /// <summary>
 /// 删除书本
 /// </summary>
 /// <param name="BooksID">书本编号</param>
 /// <returns></returns>
 public static bool DeleteBooks(int BooksID)
 {
     return(BooksDAL.DeleteBooks(BooksID));
 }
Esempio n. 26
0
 /// <summary>
 /// 修改书本信息
 /// </summary>
 /// <param name="gs"></param>
 /// <returns></returns>
 public static bool UpdateBooks(Books gs)
 {
     return(BooksDAL.UpdateBooks(gs));
 }
Esempio n. 27
0
 /// <summary>
 /// 进货
 /// </summary>
 /// <returns></returns>
 public static bool InsertbooksByBarCod(int newGoods, int oldGoods, string BarCode)
 {
     return(BooksDAL.InsertbooksByBarCod(newGoods, oldGoods, BarCode));
 }
Esempio n. 28
0
 /// <summary>
 /// 根据书本名称查询库存数
 /// </summary>
 /// <param name="goodsName"></param>
 /// <returns></returns>
 public static int GetStockNumByBooksName(string goodsName)
 {
     return(BooksDAL.GetStockNumByBooksName(goodsName));
 }
Esempio n. 29
0
        public void TestGetBookByID(int ID_Book)
        {
            BooksDAL book = new BooksDAL();

            Assert.NotNull(book.GetBookById(ID_Book));
        }
Esempio n. 30
0
        public void addBook(string Bookname, string Bookyear, string Booksummary, string Booksubject)
        {
            BooksDAL b = new BooksDAL();

            b.AddBook(Bookname, Bookyear, Booksummary, Booksubject);
        }
Esempio n. 31
0
        public void SaveBooks(bool isEditMode, Books book)
        {
            BooksDAL bdal = new BooksDAL();

            bdal.SaveBooks(isEditMode, book);
        }