public PhotoInfoViewModel() { BackCommand = new DelegateCommand(BackCommandHandler, null, false); MapCommand = new DelegateCommand(MapCommandHandler, null, false); navService = new NavigationService(); flRepository = new FlickrRepository(); exManager = new ExceptionManager(); }
public dynamic GetJson(string tags, bool cacheFlicker) { dynamic flickrRepository = null; if (cacheFlicker) flickrRepository = new FlickrCacheableRepository(); else flickrRepository = new FlickrRepository(); return Json(flickrRepository.GetImagesByTags(tags), JsonRequestBehavior.AllowGet); }
private void SearchImages(string title) { try { var flicrRepository = new FlickrRepository(); Photos = new ScrollableObservableCollection(flicrRepository.LoadImages(CurrentPage, title).Result, title); } catch (Exception ex) { exManager.PublishError(ex.Message); } }
public Windows.Foundation.IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count) { if (isRunning) //not thread safe { throw new InvalidOperationException("Only one operation in flight at a time"); } isRunning = true; int itemsCount = 0; return(AsyncInfo.Run(async c => { try { currentPage++; FlickrRepository repository = new FlickrRepository(); var result = await repository.LoadImages(currentPage, title); var photos = new PhotoCollection(); if (result != null) { photos = result; HasMoreItems = result.Any(); itemsCount = result.Count; } foreach (var item in photos) { this.Add(item); } isRunning = false; } catch (Exception ex) { HasMoreItems = false; exManager.PublishError(ex.Message); } LoadMoreItemsResult res = new LoadMoreItemsResult() { Count = (uint)itemsCount }; return res; })); }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { // Get config name string repositoryTypeName = ConfigurationManager.AppSettings["RepositoryTypeName"]; // Get type, if not configured - default type. Type type = Type.GetType(repositoryTypeName ?? "FlickrTest.Repository.FlickrRepository"); object repository = null; if (null != type) { repository = Activator.CreateInstance(type) as IRepository; } // Fallback - config value/default is not of correct type. if (null == repository) { repository = new FlickrRepository(); } IController controller = Activator.CreateInstance(controllerType, new[] { repository }) as Controller; return(controller); }
public ActionResult GetImages(string tags, bool cached = true) { // keeps a more formatted data structure for front end Dictionary <string, object> data = new Dictionary <string, object>(); if (cached) { var flickrCacheableRepository = new FlickrCacheableRepository(); data.Add("data", flickrCacheableRepository.GetImagesByTags(tags)); // mark as cached data.Add("cached", 1); return(Json(data, JsonRequestBehavior.DenyGet)); } var flickrRepository = new FlickrRepository(); data.Add("data", flickrRepository.GetImagesByTags(tags)); // mark as not cached data.Add("cached", 0); return(Json(data, JsonRequestBehavior.DenyGet)); }