Esempio n. 1
0
        public void Book_Update_Testing()
        {
            var facade = new Mock<IBookFacade>();

            var createRequest = new CreateBookRequest
            {
                Create =
                {
                    Id = 0,
                    IsActive = 1,
                    IsbnNumber = "12345",
                    Price = 566,
                    PublishedDate = DateTime.Now,
                    Remarks = "Remarks",
                    TitleB = "Book Bengali",
                    TitleE = "Book English",
                    TotalPage = 150,
                    BookCategoryId = 1,
                    Description = "desc"
                }
            };

            var success = new ResponseBase {TransactionMessage = "Data Modified Successfully", TransactionStatus = true};

            facade.Setup(x=>x.UpdateBook(createRequest)).Returns(success);
        }
Esempio n. 2
0
        public ResponseBase DeleteBook(DeleteBookRequest request)
        {
            var response = new ResponseBase();

            try
            {
                var book = _bookRepository.GetById(request.Id);
                _bookRepository.Delete(book);
                _bookUnitOfWork.Commit();

                response.TransactionMessage = "Book deleted Successfully";
                response.TransactionStatus = true;

            }
            catch (InvalidBookException ex)
            {
                response.TransactionMessage = "Book deletion failed";
                response.TransactionStatus = false;
                LoggingFactory.GetLogger().Log(ex.Message.ToString());
            }

            return response;
        }
Esempio n. 3
0
        public ResponseBase UpdateBook(CreateBookRequest request)
        {
            var response = new ResponseBase();

            try
            {
                var book = _bookRepository.GetById(request.Create.Id);
                book.BookCategoryId = request.Create.BookCategoryId;
                book.CoverPage = request.Create.CoverPage;
                book.CreationDate = DateTime.Now;
                book.Description = request.Create.Description;
                book.IsActive = request.Create.IsActive;
                book.IsbnNumber = request.Create.IsbnNumber;
                book.Price = request.Create.Price;
                book.PublishedDate = request.Create.PublishedDate;
                book.Remarks = request.Create.Remarks;
                book.TitleB = request.Create.TitleB;
                book.TitleE = request.Create.TitleE;
                book.TotalPage = request.Create.TotalPage;

                _bookRepository.Update(book);
                _bookUnitOfWork.Commit();

                response.TransactionMessage = "Data Updated Successfully";
                response.TransactionStatus = true;
            }
            catch (InvalidBookException ex)
            {
                response.TransactionMessage = "Failed to Update Data";
                response.TransactionStatus = false;
                LoggingFactory.GetLogger().Log(ex.Message.ToString());
            }

            return response;
        }
Esempio n. 4
0
        public ResponseBase SaveBook(CreateBookRequest request)
        {
            var response = new ResponseBase();

            try
            {
                var book = new Book
                {
                    BookCategoryId = request.Create.BookCategoryId,
                    CoverPage = request.Create.CoverPage,
                    CreationDate = DateTime.Now,
                    Description = request.Create.Description,
                    IsActive = request.Create.IsActive,
                    IsbnNumber = request.Create.IsbnNumber,
                    Price = request.Create.Price,
                    PublishedDate = request.Create.PublishedDate,
                    Remarks = request.Create.Remarks,
                    TitleB = request.Create.TitleB,
                    TitleE = request.Create.TitleE,
                    TotalPage = request.Create.TotalPage
                };

                _bookRepository.Save(book);
                _bookUnitOfWork.Commit();

                response.TransactionMessage = "Data Saved Successfully";
                response.TransactionStatus = true;
            }
            catch (InvalidBookException ex)
            {
                response.TransactionMessage = "Failed To Save Data";
                response.TransactionStatus = false;
                LoggingFactory.GetLogger().Log(ex.Message.ToString());
            }

            return response;
        }