Esempio n. 1
0
 private static async Task Test()
 {
     RajcePhotoProvider photoProvider = new RajcePhotoProvider();
     var photos = await photoProvider.GetPhotoList("http://doki.rajce.idnes.cz/MMM_2015/");
 }
        public async Task<ActionResult> Create([Bind(Include = "Url,Name")] PhotoAlbum photoAlbum)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    RajcePhotoProvider photoProvider = new RajcePhotoProvider();
                    var photoList = await photoProvider.GetPhotoList(photoAlbum.Url);

                    if (photoList != null
                        && photoList.Count() > 0)
                    {
                        foreach (var photo in photoList)
                        {
                            var photoModel = new Photo()
                            {
                                Url = photo.Url,
                                ThumbnailUrl = photo.ThumbnailUrl
                            };

                            photoAlbum.Photos.Add(photoModel);

                        }
                    }

                    db.PhotoAlbumSet.Add(photoAlbum);
                    await db.SaveChangesAsync();

                    await DetectBibNumbers(photoAlbum);

                    //foreach(var photo in photoAlbum.Photos)
                    //{
                    //    await DetectBibNumbers(photo);
                    //}

                    return Redirect("~/PhotoAlbums/Details/" + photoAlbum.Id);
                }
            }
            catch(Exception ex)
            {

            }
            

            return View(photoAlbum);
        }