public ActionResult Detail(Guid?id)
        {
            Book book = this.bookServices.GetById(id);
            BookDetailViewModel viewModel = new BookDetailViewModel(book);

            return(View(viewModel));
        }
Exemple #2
0
        public ActionResult Detail(int id)
        {
            BookManager         manager             = new BookManager();
            BookDetailViewModel bookDetailViewModel = manager.GetSingleBookDetail(id);

            return(View(bookDetailViewModel));
        }
Exemple #3
0
        public ActionResult Detail()
        {
            var  detailIdStr = Request.QueryString["id"];
            Guid id;

            if (Guid.TryParse(detailIdStr, out id))
            {
                var book = DataFacade.GetData <FileUpload>(x => x.Id == id).FirstOrDefault();
                if (book != null)
                {
                    var viewModel = new BookDetailViewModel();

                    var file = Server.MapPath("~/App_Data/Uploads/" + book.FileName);
                    if (System.IO.File.Exists(file))
                    {
                        try
                        {
                            Epub epub = new Epub(file);

                            viewModel.Title  = epub.Title[0];
                            viewModel.Author = string.Join(", ", epub.Creator);

                            viewModel.Epub = epub;
                            return(View(viewModel));
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
            }

            return(View(new BookDetailViewModel()));
        }
Exemple #4
0
        public BookDetailPage(Book book)
        {
            InitializeComponent();
            this._book = new BookDetailViewModel(book);

            BindingContext = this._book;
        }
Exemple #5
0
        public ActionResult Details(string code)
        {
            ViewBag.Canonical = "https://kamransehat.ir/book/" + code;

            Book book = db.Books.FirstOrDefault(current => current.Code == code && current.IsDeleted == false);

            //invalid product code
            if (book == null)
            {
                Response.StatusCode = 404;
                return(RedirectToAction("notfound", "Home"));
            }

            //Invalid Product Group


            BookDetailViewModel bookDetail = new BookDetailViewModel()
            {
                MenuProductGroups = baseViewModel.GetMenu(),
                MenuServiceGroups = baseViewModel.GetMenuServices(),
                FooterRecentBlog  = baseViewModel.GetFooterRecentBlog(),

                Book = book,
            };

            return(View(bookDetail));
        }
Exemple #6
0
        public IActionResult Update([FromForm] BookDetailViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var book = vm.Id == 0 ? new Book() : _entityContext.Books.FirstOrDefault(x => x.Id == vm.Id);

                book.Title        = vm.Title;
                book.CreationDate = vm.CreationDate;
                book.Genre        = vm.GenreId.HasValue ? _entityContext.Genre.FirstOrDefault(x => x.Id == vm.GenreId) : null;
                book.ISBN         = vm.ISBN;

                if (vm.Id == 0)
                {
                    _entityContext.Books.Add(book);
                }
                else
                {
                    _entityContext.Books.Update(book);
                }

                _entityContext.SaveChanges();

                return(Redirect("/books"));
            }
            return(View("ViewBook", vm));
        }
Exemple #7
0
        public IActionResult CreateBook([FromRoute] int id)
        {
            var vm = new BookDetailViewModel();

            vm.Title = "";
            vm.Id    = 0;
            vm.ISBN  = "";

            vm.Genres = _entityContext.Genre.Select(x => new SelectListItem
            {
                Text  = x.Name,
                Value = x.Id.ToString(),
            }
                                                    ).ToList();

            vm.Authors = _entityContext.Authors.Select(x => new SelectListItem
            {
                Text  = x.FullName,
                Value = x.Id.ToString(),
            }
                                                       ).ToList();

            vm.CreationDate = new DateTime();

            return(View("ViewBook", vm));
        }
Exemple #8
0
        /// <summary>
        /// 获取服务预定详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <BookDetailViewModel> GetBookAsync(long id, ApplicationDbContext context)
        {
            var webModel = new BookDetailViewModel();

            try
            {
                var model = await StatisticsRepository.GetEntityAsync(id, context);

                webModel.Count         = model.Count;
                webModel.DepartureTime = model.DepartureTime;
                webModel.Id            = model.Id.ToString();
                webModel.IsCancel      = model.IsCancel;
                webModel.Name          = model.Name;
                webModel.Place         = model.Place;
                webModel.Remark        = model.Remark;
                webModel.ScheduledTime = model.ScheduledTime;
                webModel.ServiceName   = model.ServiceName;
                webModel.Tel           = model.Tel;
            }
            catch (Exception ex)
            {
                _logger.LogError("获取服务预定详细信息失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message);
            }
            return(webModel);
        }
Exemple #9
0
        public IActionResult Detail([FromRoute] int id)
        {
            var book = GetFullGraph()
                       .FirstOrDefault(x => x.Id == id);

            if (book == null)
            {
                var vm2 = new BookDetailViewModel
                {
                    Id           = 0,
                    Title        = "",
                    CreationDate = DateTime.Now,
                    Author       = "",
                    Genre        = "",
                    GenreId      = 0
                };
                return(View(vm2));
            }

            var vm = ConvertBook(book);

            vm.Genres = _entityContext.Genre.Select(x => new SelectListItem
            {
                Text  = x.Name,
                Value = x.Id.ToString(),
            }
                                                    ).ToList();
            return(View(vm));
        }
Exemple #10
0
        public IActionResult Detail(int id)
        {
            var book = context.Books.FirstOrDefault(i => i.Id == id);

            book.ViewCount = book.ViewCount + 1;
            context.SaveChanges();

            BookDetailViewModel data = new BookDetailViewModel()
            {
                BookName    = book.Name,
                BookTitle   = book.Title,
                ImageUrl    = book.ImageUrl,
                ViewedCount = book.ViewCount,
                //AuthorName=book.Author.AuthorName
            };


            var entity = context.Books
                         .Include(i => i.Author)
                         .Where(i => i.Id == id)
                         .Select(i => new BookDetailViewModel
            {
                BookName    = i.Name,
                BookTitle   = i.Title,
                ImageUrl    = i.ImageUrl,
                ViewedCount = i.ViewCount,
                AuthorName  = i.Author.AuthorName
            }).FirstOrDefault();

            return(View(entity));
        }
        /// <summary>
        /// Setting book to be updated, if user has clicked the input field
        /// </summary>
        /// <param name="sender">The source of the event</param>
        /// <param name="e">The instance containing the event data</param>
        private void txtBox_GotFocus(object sender, RoutedEventArgs e)
        {
            BookDetailViewModel viewmodel = (BookDetailViewModel)DataContext;
            Book book = viewmodel.MyBook;

            book.IsUpdated  = true;
            Books.IsUpdated = true;
        }
Exemple #12
0
        // GET: Books/Details/5
        public ActionResult Details(int id)
        {
            var bookDto = this.booksUseCase.GetBookDetail(id);
            var book    = new BookDetailViewModel {
                Id = bookDto.Id, ISBN = bookDto.ISBN, Name = bookDto.Name, Price = bookDto.Price.ToString("0.00")
            };

            return(View(book));
        }
 /// <summary>
 /// Checking that the book's title is not empty
 /// </summary>
 /// <param name="sender">The source of the event</param>
 /// <param name="e">The instance containing the event data</param>
 private void TxtBookTitle_LostFocus(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(txtBookTitle.Text))
     {
         MessageBox.Show("Field cannot be empty!");
         BookDetailViewModel viewmodel = (BookDetailViewModel)DataContext;
         Book book = viewmodel.MyBook;
         txtBookTitle.Text = book.Title;
     }
 }
        public AddBook(Book book = null)
        {
            InitializeComponent();

            Book editingBook = book ?? new Book();

            this._book = new BookDetailViewModel(editingBook);

            BindingContext = this._book;
        }
Exemple #15
0
        public ActionResult Detail(string id)
        {
            var book = BooksController._library.SingleOrDefault(b => b.Id == Guid.Parse(id));

            this.ConfigureMetadata();
            this.InitializeMetadataDetailsViewBag(book);

            var viewModel = new BookDetailViewModel(book);

            return(this.View(viewModel));
        }
Exemple #16
0
        public IActionResult Detail([FromRoute] int id)
        {
            return(View());

            var bookDetailViewModel = new BookDetailViewModel();

            bookDetailViewModel.Author = "author " + id;
            bookDetailViewModel.ISBN   = "isbn" + id;
            bookDetailViewModel.Title  = "title" + id;

            return(View(bookDetailViewModel));
        }
Exemple #17
0
        public ActionResult Detail(int id)
        {
            var model = new BookDetailViewModel
            {
                Book              = _bookService.GetBookDetail(id),
                BookImages        = _bookImageService.GetImagesForBook(id),
                BookReviews       = _reviewService.GetReviewsForBook(id),
                RelatedCategories = _categoryService.GetRelatedCategoriesByBookId(id)
            };

            return(View(model));
        }
Exemple #18
0
        private static BookDetailViewModel ConvertToNewModel(Book book)
        {
            var vm = new BookDetailViewModel();

            vm.Title        = book.Title;
            vm.Id           = book.Id;
            vm.ISBN         = book.ISBN;
            vm.CreationDate = book.CreationDate;
            vm.Genre        = book.Genre?.Name;
            vm.Author       = String.Join(", ", book.Authors.Select(x => x.Author.FullName));
            return(vm);
        }
Exemple #19
0
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id is null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var book = await booksRepository.GetSelectedAsync((Guid)id);

            var vm = new BookDetailViewModel(book);

            return(View(vm));
        }
 /// <summary>
 /// Checking if the input in book's year's field is valid
 /// </summary>
 /// <param name="sender">The source of the event</param>
 /// <param name="e">The instance containing the event data</param>
 private void TxtYear_LostFocus(object sender, RoutedEventArgs e)
 {
     if (int.TryParse(txtYear.Text, out int year))
     {
         if (year < 1 || year > 2050)
         {
             MessageBox.Show("Year field not valid.");
             BookDetailViewModel viewmodel = (BookDetailViewModel)DataContext;
             Book book = viewmodel.MyBook;
             txtYear.Text = book.YearPublish.ToString();
         }
     }
 }
Exemple #21
0
        private static BookDetailViewModel ConvertBook(Book book)
        {
            var vm = new BookDetailViewModel
            {
                Id           = book.Id,
                Title        = book.Title,
                CreationDate = book.CreationDate,
                Author       = string.Join(";", book.Authors.Select(x => x.Author.FullName)),
                Genre        = book.Genre?.Name,
                GenreId      = book.Genre?.Id
            };

            return(vm);
        }
Exemple #22
0
        public IActionResult Detail(string id)
        {
            var bookDetail          = _bookRepository.GetBook(id);
            var relatedBook         = _bookRepository.RelatedBooks(id);
            var booktype            = _bookTypeRepository.GetById(bookDetail.BookTypeId);
            var linkDownloads       = _downloadFormat.GetLinkDownloads(bookDetail.FormatDownload);
            var bookDetailViewModel = new BookDetailViewModel
            {
                BookDetail    = bookDetail,
                BookType      = booktype,
                RelatedBooks  = relatedBook,
                DownloadLinks = linkDownloads
            };

            return(View(bookDetailViewModel));
        }
Exemple #23
0
        public ActionResult Index(int Id)
        {
            var productService = new ProductService();
            var product        = productService.Get(Id);
            var model          = new BookDetailViewModel();

            model.Auther       = product.Author;
            model.CategoryName = product.CategoryName;
            model.Detail       = product.Detail;
            model.Image        = String.Concat(Url.Content("~/Content/images/Product/"), product.Image, ".jpg");
            model.Isbn         = product.Isbn;
            model.Price        = product.Price;
            model.Title        = product.Title;
            model.Balance      = product.Balance;
            model.Id           = product.Id;
            return(View(model));
        }
Exemple #24
0
        public IActionResult ViewBook([FromRoute] int id)
        {
            var instance = _entityContext.Books.Include(x => x.Authors).ThenInclude(x => x.Author).FirstOrDefault(x => x.Id == id);


            if (instance == null)
            {
                var vm = new BookDetailViewModel();
                vm.Title        = "";
                vm.Id           = 0;
                vm.ISBN         = "";
                vm.CreationDate = DateTime.Now;
                vm.Genre        = "";
                vm.Author       = "";

                vm.Genres = _entityContext.Genre.Select(x => new SelectListItem
                {
                    Text  = x.Name,
                    Value = x.Id.ToString(),
                }
                                                        ).ToList();

                return(View(vm));
            }
            else
            {
                var vm = ConvertToNewModel(instance);

                vm.Genres = _entityContext.Genre.Select(x => new SelectListItem
                {
                    Text  = x.Name,
                    Value = x.Id.ToString(),
                }
                                                        ).ToList();

                vm.Authors = _entityContext.Authors.Select(x => new SelectListItem
                {
                    Text  = x.FullName,
                    Value = x.Id.ToString(),
                }
                                                           ).ToList();

                return(View(vm));
            }
        }
        public BookDetailViewModelTests()
        {
            var eventAggregatorMock            = new Mock <IEventAggregator>();
            var booksRepoMock                  = new Mock <IRepository <Book> >();
            var languageLookupDataServiceMock  = new Mock <ILanguageLookupDataService>();
            var publisherLookupDataServiceMock = new Mock <IPublisherLookupDataService>();
            var authorLookupDataServiceMock    = new Mock <IAuthorLookupDataService>();
            var formatLookupDataServiceMock    = new Mock <IFormatLookupDataService>();
            var genreLookupDataServiceMock     = new Mock <IGenreLookupDataService>();
            var formatRepositoryMock           = new Mock <IFormatRepository>();
            var genreRepositoryMock            = new Mock <IGenreRepository>();
            var dialogService                  = new DialogService();

            var loggerMock  = new Mock <ILogger>();
            var bookService = new BookService(booksRepoMock.Object, formatRepositoryMock.Object, genreRepositoryMock.Object, languageLookupDataServiceMock.Object, publisherLookupDataServiceMock.Object, authorLookupDataServiceMock.Object, formatLookupDataServiceMock.Object, genreLookupDataServiceMock.Object);

            viewModel = new BookDetailViewModel(eventAggregatorMock.Object, loggerMock.Object, bookService, dialogService);
        }
        public async Task <ActionResult> Details(int id)
        {
            var book = await _bookServices.GetByIdAsync(id);

            if (book == null)
            {
                return(HttpNotFound());
            }

            var user = User.Identity.GetApplicationUser();


            var bookDetailViewModel = new BookDetailViewModel()
            {
                Book = book
            };

            return(View(bookDetailViewModel));
        }
Exemple #27
0
        public async Task <IActionResult> Detail(int id)
        {
            var book = await _bookRepository.Get(id);

            if (book == null)
            {
                return(NotFound());
            }

            var viewModel = new BookDetailViewModel
            {
                Title      = book.Title,
                Summary    = book.Summary,
                Price      = book.Price,
                AuthorName = $"{book.Author.LastName}, {book.Author.FirstName}"
            };

            return(View(viewModel));
        }
        public BookDetailViewModel GetBookDetail(int BookID)
        {
            var bookEntity = unitOfWork.BookRepository
                             .Get(null, null, "BookAssignations,BookAssignations.AssignedPerson").Where(x => x.ID == BookID)
                             .SingleOrDefault();

            if (bookEntity != null)
            {
                BookDetailViewModel bookDetailViewModel =
                    new BookDetailViewModel()
                {
                    BookID                = bookEntity.ID,
                    BookTitle             = bookEntity.BookTitle,
                    ISBN                  = bookEntity.ISBN,
                    CheckInOutStatus      = bookEntity.CheckInCheckOut.HasValue ? bookEntity.CheckInCheckOut.ToString() : "None",
                    CoverPrice            = bookEntity.CoverPrice,
                    PublishYear           = bookEntity.PublishDate.Year,
                    CurrentAssignedPerson = bookEntity.BookAssignations.Where(x => !x.CheckInDate.HasValue).OrderByDescending(x => x.CheckInDate)
                                            .Select(y => new AssignedPersonViewModel
                    {
                        MobileNumber = y.AssignedPerson.MobileNumber,
                        NationalID   = y.AssignedPerson.NationalID,
                        PersonName   = y.AssignedPerson.PersonName
                    }).SingleOrDefault(),
                    BookAssignationHistory = bookEntity.BookAssignations.OrderByDescending(x => x.CheckInDate)
                                             .Select(z => new BookAssinationViewModel()
                    {
                        AssignedPerson = new AssignedPersonViewModel
                        {
                            MobileNumber = z.AssignedPerson.MobileNumber,
                            NationalID   = z.AssignedPerson.NationalID,
                            PersonName   = z.AssignedPerson.PersonName
                        },
                        CheckInDate  = z.CheckInDate.GetValueOrDefault(),
                        CheckOutDate = z.CheckOutDate
                    }).ToList()
                };

                return(bookDetailViewModel);
            }

            return(null);
        }
Exemple #29
0
        public List <BookDetailViewModel> GetAllBookByUser(string userId)
        {
            List <Book> books = db.Books.Where(x => x.UserId == userId).ToList();
            List <BookDetailViewModel> bookList = new List <BookDetailViewModel>();

            foreach (Book book in books)
            {
                IQueryable <Photo> photo = from p in db.Photos
                                           where p.Book.Id == book.Id
                                           select p;

                List <Photo> photos = photo.ToList();

                List <Department> departments = book.Departments.ToList();
                Department        department  = db.Departments.Find(departments[0].Id);

                string    date      = String.Format("{0:d MMM, yyyy}", book.UploadDateTime);
                Condition condition = db.Conditions.Find(book.Condition.Id);

                Category category = db.Categories.Find(book.Category.Id);


                BookDetailViewModel bookDetail = new BookDetailViewModel()
                {
                    Author         = book.Author,
                    Photo          = photos[0].Path,
                    Price          = book.Price,
                    Title          = book.Title,
                    Id             = book.Id,
                    UploadDateTime = date,
                    Condition      = condition.Name,
                    Department     = department.Name,
                    Category       = category.Name,
                    AdditionalInfo = book.AdditionalInfo,
                    Edition        = Utils.getEdition(book.Edition),
                    ContactNo      = book.ApplicationUser.PhoneNumber,
                    Email          = book.ApplicationUser.Email
                };

                bookList.Add(bookDetail);
            }
            return(bookList);
        }
Exemple #30
0
        public async Task <ApiResult <object> > GetBookByUrl(string url)
        {
            var book = await eShopDb.Books.FirstOrDefaultAsync(x => x.Url == url);

            if (book == null)
            {
                return(new ApiResult <object>(success: false, messge: "Không tìm thấy sách", payload: null));
            }

            if (book.isDelete == true)
            {
                return(new ApiResult <object>(success: false, messge: "Sách đã bị xóa", payload: null));
            }

            var result = new BookDetailViewModel()
            {
                id          = book.Id,
                name        = book.Name,
                author      = book.Author,
                categoryId  = book.CategoryId,
                category    = book.Category.Name,
                available   = book.Available,
                price       = book.Price,
                sale        = book.Sale,
                image       = book.BookImage,
                description = book.Description,
                keyWord     = book.KeyWord,
                url         = book.Url,

                comments = book.BookRatings.Select(x => new RatingViewModel()
                {
                    id       = x.Id,
                    userId   = x.UserId,
                    username = x.User.FullName,
                    comment  = x.Comment,
                    rating   = x.Rating,
                    avatar   = x.User.Avatar,
                }).ToList(),
            };

            return(new ApiResult <object>(success: true, messge: "Thành công", payload: new { book = result }));
        }