Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            BookUnitOfWork uow = new BookUnitOfWork(new BookModel());

            AddBooks(uow);
            GetBooks(uow);
        }
Ejemplo n.º 2
0
        private static void GetBooks(BookUnitOfWork uow)
        {
            var books = uow.ExecuteSelectProcedure <BookSummary>("spGetBooks", new object[] { "" });

            foreach (var book in books)
            {
                Console.WriteLine("Name {0}, Author {1}, Publisher {2}", book.BookName, book.Author, book.Publisher);
            }
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        private static void AddBooks(BookUnitOfWork uow)
        {
            //var book = uow.tblBooks.Insert(new tblBook() { Name = "A" });
            //uow.tblBookDetails.Insert(new tblBookDetail() { Author = "Author1", BookID = book.BookID, Publisher = "P1", tblBook = book });

            //book = uow.tblBooks.Insert(new tblBook() { Name = "B" });
            //uow.tblBookDetails.Insert(new tblBookDetail() { Author = "Author2", BookID = book.BookID, Publisher = "P1", tblBook = book });

            //book = uow.tblBooks.Insert(new tblBook() { Name = "C" });
            //uow.tblBookDetails.Insert(new tblBookDetail() { Author = "Author3", BookID = book.BookID, Publisher = "P1", tblBook = book });

            uow.ExecuteCommandProcedure("spInsertBook", new object[] { "A", "Author1", "P1" });
            uow.ExecuteCommandProcedure("spInsertBook", new object[] { "B", "Author1", "P2" });
            uow.ExecuteCommandProcedure("spInsertBook", new object[] { "C", "Author2", "P2" });
            uow.ExecuteCommandProcedure("spInsertBook", new object[] { "D", "Author2", "P1" });
            uow.ExecuteCommandProcedure("spInsertBook", new object[] { "E", "Author3", "P1" });

            uow.Save();
        }
        public void Book_Save_Testing()
        {
            var context            = new Mock <IBookDbContext>();
            var bookUnitOfWork     = new BookUnitOfWork(context.Object);
            var bookRepository     = new Mock <IBookRepository>();
            var categoryRepository = new Mock <ICategoryRepository>();
            var facade             = new BookFacade(bookRepository.Object, categoryRepository.Object, bookUnitOfWork);
            //var createRequest = new Mock<CreateBookRequest>();
            //createRequest.Object.Create.Id = 0;
            //createRequest.Object.Create.IsActive = 1;
            //createRequest.Object.Create.IsbnNumber = "12345";
            //createRequest.Object.Create.Price = 566;
            //createRequest.Object.Create.PublishedDate = DateTime.Now;
            //createRequest.Object.Create.Remarks = "Remarks";
            //createRequest.Object.Create.TitleB = "Book Bengali";
            //createRequest.Object.Create.TitleE = "Book English";
            //createRequest.Object.Create.TotalPage = 150;
            //createRequest.Object.Create.BookCategoryId = 1;
            //createRequest.Object.Create.Description = "desc";

            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"
                }
            };

            facade.SaveBook(createRequest);
        }
Ejemplo n.º 5
0
 public Bookshelf(ApiContext context)
 {
     _unitOfWork = new BookUnitOfWork(context);
 }
Ejemplo n.º 6
0
 public BookController(ApiContext context)
 {
     _unitOfWork = new BookUnitOfWork(context);
 }
Ejemplo n.º 7
0
 public BooksController(BookUnitOfWork b, IMapper mapper)
 {
     bookUnitOfWork = b;
     Mapper         = mapper;
 }