public ScannedPageFacadeTest() 
        {
            _scannedPageMapper = new ScannedPageMapper();

            _fixture = new Fixture();
            _fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
            _fixture.Behaviors.Add(new OmitOnRecursionBehavior());
            _fixture.Customizations.Add(new TypeRelay(typeof(Item), typeof(Book)));
            _fixture.Customizations.Add(new TypeRelay(typeof(ItemBusinessModel), typeof(BookBusinessModel)));

            _scannedPage = _fixture.Create<ScannedPage>();
            _scannedPageBusinessModel = _fixture.Create<ScannedPageBusinessModel>();

            _readerBusinessModel = _fixture.Create<ReaderBusinessModel>();
            ReaderMapper readerMapper = new ReaderMapper();
            _reader = readerMapper.Map(_readerBusinessModel);

            _itemBusinessModel = _fixture.Create<ItemBusinessModel>();
            ItemMapper itemMapper = new ItemMapper();
            _item = itemMapper.Map(_itemBusinessModel);

            this.uow = Initializer.GetLibraryUow();
            uow.ScannedPages.Add(this._scannedPage);
            uow.Readers.Add(this._reader);
            uow.Items.Add(this._item);
            this._scannedPageFacade = new ScannedPageFacade(uow);
        }
 public ActionResult Edit(ScannedPageBusinessModel model)
 {
     var scannedPage = this.scannedPageManager.GetScannedPageById(model.Id);
     scannedPage.IsLocked = model.IsLocked;
     scannedPage.IsReady = model.IsReady;
     scannedPage.OrderText = model.OrderText;
     scannedPage.OrderDate = model.OrderDate;
     scannedPage.Message = model.Message;
     this.scannedPageManager.UpdateScannedPage(scannedPage);
     return RedirectToAction("Index");
 }
        public ScannedPageMapperTests()
        {
            this._scannedPageMapper = new ScannedPageMapper();

            Fixture fixture = new Fixture { RepeatCount = 1 };
            fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
            fixture.Behaviors.Add(new OmitOnRecursionBehavior());
            fixture.Customizations.Add(new TypeRelay(typeof(Item), typeof(Book)));
            fixture.Customizations.Add(new TypeRelay(typeof(ItemBusinessModel), typeof(BookBusinessModel)));

            Reader reader = fixture.Create<Reader>();
            ReaderMapper readerMapper = new ReaderMapper();
            var readerModel = readerMapper.Map(reader);

            var item = fixture.Create<Item>();
            var itemMapper = new ItemMapper();
            var itemModel = itemMapper.Map(item);

            _scannedPage = fixture.Create<ScannedPage>();
            _scannedPageBusinessModel = fixture.Create<ScannedPageBusinessModel>();
        }
        public ActionResult CreateOrder(int Id, ScannedPageBusinessModel scannedPage)
        {
            try
            {
                var reader = this.readerManager.GetReaderByUserId(WebSecurity.CurrentUserId);
                var item = this.itemManager.GetItemById(Id);

                scannedPage.Reader = reader;
                scannedPage.Item = item;

                //this.scannedPageManager.ScanPages(readerId, Id, scannedPage);
                this.scannedPageManager.CreateScanPages(scannedPage);
            }
            catch
            {
                return RedirectToAction("Index");
            }

            return RedirectToAction("Index");
        }
        //[Authorize(Roles = "Admin, Librarian, Registered")]
        //public ActionResult Add()
        //{
        //    return View();
        //}

        //public ActionResult CreateOrder(int Id)
        //{
        //    Session["bookId"] = Id;
        //    return View();
        //}

        //[HttpPost]
        //public string CreateOrder(int bookId, ScannedPageBusinessModel scannedPage)
        //{
        //    int readerId;

        //    try
        //    {
        //        bookId = bookManager.GetBookById(bookId).Id;
        //        readerId = readerManager.GetReaderByUserId(WebSecurity.CurrentUserId).ReaderId;
        //    }
        //    catch
        //    {
        //        return "You must be Reader in order to reserve books";
        //    }

        //    return this.scannedPageManager.ScanPages((int)readerId, bookId, scannedPage);

        //}


        public ActionResult CreateOrder(int Id)
        {
            ItemBusinessModel item = this.itemManager.GetItemById(Id);
            ScannedPageBusinessModel mySkanPage = new ScannedPageBusinessModel();
            mySkanPage.Item = item;
            mySkanPage.OrderText = "{start page}-{end page}(count copies); \n For example: \n{1}-{3}(1);\n{11}-{13}(1);";
            return View(mySkanPage);
        }
 public void ScannedPageModelToEntityMappingIsNullTest()
 {
     _scannedPageBusinessModel = null;
     var result = _scannedPageMapper.Map(_scannedPageBusinessModel);
     Assert.IsNull(result);
 }
 public void CreateScanPages(ScannedPageBusinessModel scannedPage)
 {
     this.scannedPageFacade.CreateScanPages(scannedPage);
 }
 public string ScanPages(int readerId, int bookId, ScannedPageBusinessModel scannedPage)
 {
     return this.scannedPageFacade.ScanPages(readerId, bookId, scannedPage);
 }
 public void UpdateScannedPage(ScannedPageBusinessModel scannedPage)
 {
     this.scannedPageFacade.UpdateScannedPage(scannedPage);
 }