Ejemplo n.º 1
0
 public Task<Movie> SaveMovie(Movie movie)
 {
     return Task.Factory.StartNew(() =>
     {
         db.SaveItem<Movie>(movie);
         return movie;
     });
 }
Ejemplo n.º 2
0
        public async Task Init(int id)
        {
            if (id >= 0)
            {
                currentMovie = 
                    //caching a movie
                    await storageService.GetMovie(id) ?? 
                    await movieService.GetMovie(id);
            }
            else
            {
                currentMovie = null;
            }

            Init();
        }
Ejemplo n.º 3
0
        public async Task ExecuteDeleteMovieCommand(Movie movie)
        {
            if (IsBusy)
                return;

            IsBusy = true;
            try
            {
                await storageService.DeleteMovie(movie.Id);
            }
            catch (Exception)
            {
                Debug.WriteLine("Unable to delete movie");
            }
            finally
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 4
0
 public void Init(Movie movie)
 {
     currentMovie = movie;
     Init();
 }
Ejemplo n.º 5
0
        public async Task ExecuteSaveMovieCommand()
        {
            if (IsBusy)
                return;
            if (currentMovie == null)
                currentMovie = new Movie();

            currentMovie.Title = Title;
            currentMovie.ImdbId = ImdbId;
            currentMovie.Runtime = Runtime;
            currentMovie.IsFavorite = IsFavorite;
            if(Image != null)
                currentMovie.Image = Image.ConvertToByte();

            try
            {
                await storageService.SaveMovie(currentMovie);
                ServiceContainer.Resolve<MoviesViewModel>().NeedsUpdate = true;
            }
            catch (Exception)
            {
                Debug.WriteLine("Unable to save favorite.");
            }
            finally
            {
                IsBusy = false;
            }
        }
 public MovieViewController(Movie movie) : base(UITableViewStyle.Plain, null, true)
 {
     this.movie = movie;
     viewModel = ServiceContainer.Resolve<MovieViewModel>();
     viewModel.Init(this.movie);
 }