// GET: Books public ActionResult AddBook() { LivreCategorieViewModel viewModel = new LivreCategorieViewModel(); viewModel.Livre = new Livre(); viewModel.Categories = contextCategory.Collection().ToList(); ViewBag.FirstStep = true; return(View(viewModel)); }
public async Task <PartialViewResult> AddPartialBook(Livre livre) { if (ModelState.IsValid) { string isbnString = livre.ISBN.ToString(); string title = "", auteur = "", editionDate = "", image = "", description = ""; double price = 0.0, nbrePoints = 0.0, avancePoints = 0.0; try { title = await service.GetTitle(isbnString); price = await service.GetPrice(isbnString); nbrePoints = service.GetPoints(price, EtatDuLivre.COMMENEUF); avancePoints = service.GetPoints(price, EtatDuLivre.COMMENEUF, livre.IsExchange); editionDate = await service.GetDateEdition(isbnString); image = await service.GetImage(isbnString); description = await service.GetDescription(isbnString); auteur = await service.GetAuthors(isbnString); } catch (BookNotFoundException bookException) { ViewBag.ExceptionBook = bookException.Message; return(PartialView()); } livre.Author = auteur; livre.ISBN = Convert.ToInt64(isbnString); livre.Title = title; livre.Image = image; livre.Description = description; livre.Price = price; livre.PointDuLivre = nbrePoints; livre.AvancePoints = avancePoints; livre.DateEdition = editionDate; /* livre.DateEdition = DateTime.Parse(editionDate).Year; */ LivreCategorieViewModel viewModel = new LivreCategorieViewModel(); viewModel.Livre = livre; viewModel.Categories = contextCategory.Collection().ToList(); return(PartialView("_BookInfos", viewModel)); } else { return(PartialView()); } /* string author = service.GetEdithor(isbnString); * string editionDate = service.GetDateEdition(isbnString); * string langauge = service.GetLanguage(isbnString); * int volume = service.GetVolume(isbnString); * List<string> categories = service.GetCategories(isbnString); * string dimension = service.GetDimension(isbnString); * string description = service.GetDescription(isbnString); * double criticalBook = service.GetAverageRatingCritical(isbnString); */ //Calcul du nombre de points }