示例#1
0
        public void Given_AddBook_DataNull_Return_BadRequest()
        {
            BookShowModel data     = null;
            var           response = bookController.AddBook(data);

            Assert.IsType <BadRequestObjectResult>(response);
        }
        public IActionResult AddBook(BookShowModel bookShowModel)
        {
            try
            {
                if (bookShowModel != null)
                {
                    var data = this.bookBL.AddBook(bookShowModel);
                    if (data != null)
                    {
                        return(this.Ok(new { status = "True", message = "Book Added Successfully", data }));
                    }
                    else
                    {
                        return(this.BadRequest(new { status = "False", message = "Failed To Add Book" }));
                    }
                }
                else
                {
                    return(this.BadRequest(new { status = "False", message = "Failed To Add Book" }));
                }
            }

            catch (Exception exception)
            {
                return(BadRequest(new { message = exception.Message }));
            }
        }
示例#3
0
 public BookAddModel AddBook(BookShowModel bookShowModel)
 {
     try
     {
         var response = this.bookRL.AddBook(bookShowModel);
         return(response);
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
示例#4
0
        public void Given_AddBook_Data_Valid()
        {
            var data = new BookShowModel()
            {
                BooKTitle = "mvc",
                Author    = "microsoft",
                Language  = "English",
                Category  = "Tech",
                ISBN      = 1290,
                Price     = 123,
                Pages     = 123
            };
            var response = bookController.AddBook(data);

            Assert.IsType <OkObjectResult>(response);
        }
示例#5
0
        public ActionResult BookShow(int id)
        {
            BookShowModel model = new BookShowModel();
            Rep_Book      rep_b = new Rep_Book();
            Rep_File      rep_f = new Rep_File();

            model.Book = db.Tbl_Book.Where(a => a.Book_ID == id).SingleOrDefault();

            model.DetailsNav = rep_b.Get_BookDetailsListByBookType(model.Book.Book_BookTypeID);

            model.Details = model.Book.Tbl_BookDetails;

            if (model.Details.BD_FileEnabel)
            {
                model.Files = rep_f.FilesByBookID(id);
            }
            model.Tags = new List <string>();
            model.Tags = rep_b.Get_TagsByBookID(id);

            return(View(model));
        }
示例#6
0
        /// <summary>
        /// add book
        /// </summary>
        /// <param name="bookShowModel"></param>
        /// <returns></returns>
        public BookAddModel AddBook(BookShowModel bookShowModel)
        {
            try
            {
                DatabaseConnection databaseConnection         = new DatabaseConnection(this.configuration);
                List <StoredProcedureParameterData> paramList = new List <StoredProcedureParameterData>();
                paramList.Add(new StoredProcedureParameterData("@Book_Title", bookShowModel.BooKTitle));
                paramList.Add(new StoredProcedureParameterData("@Author", bookShowModel.Author));
                paramList.Add(new StoredProcedureParameterData("@Language", bookShowModel.Language));
                paramList.Add(new StoredProcedureParameterData("@Category", bookShowModel.Category));
                paramList.Add(new StoredProcedureParameterData("@ISBN_No", bookShowModel.ISBN));
                paramList.Add(new StoredProcedureParameterData("@Price", bookShowModel.Price));
                paramList.Add(new StoredProcedureParameterData("@Pages", bookShowModel.Pages));
                paramList.Add(new StoredProcedureParameterData("@CreatedDate", DateTime.Now));
                paramList.Add(new StoredProcedureParameterData("@ModifiedDate", DateTime.Now));
                DataTable table    = databaseConnection.StoredProcedureExecuteReader("AddBook", paramList);
                var       bookData = new BookAddModel();

                foreach (DataRow dataRow in table.Rows)
                {
                    bookData              = new BookAddModel();
                    bookData.Id           = (int)dataRow["Id"];
                    bookData.BooKTitle    = dataRow["Book_Title"].ToString();
                    bookData.Author       = dataRow["Author"].ToString();
                    bookData.Language     = dataRow["Language"].ToString();
                    bookData.Category     = dataRow["Category"].ToString();
                    bookData.ISBN         = Convert.ToInt32(dataRow["ISBN_No"]);
                    bookData.Price        = Convert.ToInt32(dataRow["Price"]);
                    bookData.Pages        = Convert.ToInt32(dataRow["Pages"]);
                    bookData.CreatedDate  = Convert.ToDateTime(dataRow["CreatedDate"]);
                    bookData.ModifiedDate = Convert.ToDateTime(dataRow["ModifiedDate"]);
                }
                return(bookData);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }