Example #1
0
 /// <summary>
 /// default constructor
 /// </summary>
 public DetailsPageViewModel()
 {
     Details = new ImportantDetails()
     {
         Pages      = 0,
         Title      = "nincs adat",
         AuthorName = "nincs adat",
         AuthorUrl  = "nincs adat"
     };
     _searchService = new SearchService();
 }
Example #2
0
        /// <summary>
        /// create the good url for the api call, and call the service function with it. And make the new detailsBook with the result
        /// </summary>
        public async Task GetData()
        {
            String newUrl;

            if (BookEntity.Isbn.Length > 0)
            {
                newUrl = ("/api/books?bibkeys=ISBN:" + BookEntity.Isbn[0] + "&jscmd=data&format=json");
            }
            else if (BookEntity.Lccn.Length > 0)
            {
                newUrl = ("/api/books?bibkeys=LCCN:" + BookEntity.Lccn[0] + "&jscmd=data&format=json");
            }
            else if (BookEntity.Oclc.Length > 0)
            {
                newUrl = ("/api/books?bibkeys=OCLC:" + BookEntity.Oclc[0] + "&jscmd=data&format=json");
            }
            else
            {
                throw new Exception("wrong url for details");
            }

            var result = await _searchService.GetDetails(newUrl);

            ImageSource imgt;

            if (result.Cover != null)
            {
                imgt = _searchService.GetImgFromUrl(result.Cover.Large);
            }
            else
            {
                imgt = _searchService.GetImgFromUrl(null);
            }

            ImportantDetails temp = new ImportantDetails
            {
                Img        = imgt,
                Pages      = result.Number_of_pages,
                Title      = "nincs adat",
                ImageL     = "nincs adat",
                ImageM     = "nincs adat",
                AuthorName = "nincs adat",
                AuthorUrl  = "nincs adat"
            };

            if (result.Title != null)
            {
                temp.Title = result.Title;
            }
            if (result.Cover != null)
            {
                temp.ImageL = result.Cover.Large;
                temp.ImageM = result.Cover.Medium;
            }
            if (result.Authors.Length > 0)
            {
                temp.AuthorName = result.Authors[0].Name;
                temp.AuthorUrl  = result.Authors[0].Url;
            }
            Details = temp;
        }