async Task ExecuteLoadFilmsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var filmsCount = await filmService.FilmsCount();

                pagesCount = (int)Math.Ceiling((double)filmsCount / AppConstants.PAGE_SIZE);

                FilmTreshold = 4;
                Films.Clear();
                var films = await filmService.GetAllFilms();

                Films.AddRange(films);
                FilteredFilms.AddRange(films);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#2
0
        async Task LoadData()
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;
                Films.Clear();
                var resulFilms = await Api.GetFilmsByListUrl(People.Films);

                foreach (var film in resulFilms)
                {
                    Films.Add(film);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error when load data: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                await ShowAlertAsync("Error when load data!", error.Message, "OK");
            }
        }
示例#3
0
        private void SearchComedi()
        {
            Films.Clear();
            string sqlExpression = "SELECT * FROM Films where Genre ='Комедия'";

            if (DataBase.SqlConnection.State != System.Data.ConnectionState.Open)
            {
                DataBase.SqlConnection.Open();
            }

            if (DataBase.SqlConnection.State == System.Data.ConnectionState.Open)
            {
                SqlCommand    command = new SqlCommand(sqlExpression, DataBase.SqlConnection);
                SqlDataReader reader  = command.ExecuteReader();

                if (reader.HasRows)       // если есть данные
                {
                    while (reader.Read()) // построчно считываем данные
                    {
                        object film_id     = reader["Film_id"];
                        object title       = reader["Title"];
                        object genre       = reader["Genre"];
                        object year        = reader["Year"];
                        object description = reader["Description"];
                        object status      = reader["Status"];


                        Films.Add(new Film(Convert.ToInt32(film_id.ToString()), title.ToString(),
                                           genre.ToString(), Convert.ToInt32(year.ToString()), description.ToString(), status.ToString()));
                    }
                }
                reader.Close();
            }
            DataBase.SqlConnection.Close();
        }
示例#4
0
        async Task ExecuteLoadFilmsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Films.Clear();
                var filmsResponse = await ServiceSource.GetFilmsAsync(true);

                foreach (var film in filmsResponse)
                {
                    Films.Add(film);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#5
0
 public void Delete()
 {
     Books.Clear();
     Films.Clear();
     Serials.Clear();
     Comments.Clear();
     IsDeleted = true;
 }
示例#6
0
        private void SearchDatabase(string text)
        {
            Films.Clear();
            Persons.Clear();
            Reviews.Clear();

            if (String.IsNullOrWhiteSpace(text))
            {
                return;
            }
            text = PrepareString(text);

            var films = _filmRepository.GetAll();

            foreach (var film in films)
            {
                var detail = _filmRepository.GetById(film.Id);

                if (PrepareString(detail.OriginalName).Contains(text, StringComparison.CurrentCultureIgnoreCase) ||
                    PrepareString(detail.CzechName).Contains(text, StringComparison.CurrentCultureIgnoreCase) ||
                    PrepareString(detail.Country).Contains(text, StringComparison.CurrentCultureIgnoreCase) ||
                    PrepareString(detail.Description).Contains(text, StringComparison.CurrentCultureIgnoreCase))
                {
                    Films.Add(film);
                }
            }

            var persons = _personRepository.GetAll();

            foreach (var person in persons)
            {
                var detail = _personRepository.GetById(person.Id);
                var name   = detail.FirstName + detail.LastName;

                if (PrepareString(name).Contains(text, StringComparison.CurrentCultureIgnoreCase))
                {
                    Persons.Add(person);
                }
            }

            var reviews = _reviewRepository.GetAll();

            foreach (var review in reviews)
            {
                var detail = _reviewRepository.GetById(review.Id);

                if (PrepareString(detail.TextReview).Contains(text, StringComparison.CurrentCultureIgnoreCase))
                {
                    Reviews.Add(review);
                }
            }
        }
示例#7
0
        public async Task SearchForMovie(string title)
        {
            Films.Clear();
            try
            {
                SearchContainer <SearchMovie> results = await Client.SearchMovieAsync(title);

                foreach (SearchMovie movie in results.Results.OrderByDescending(m => m.VoteAverage))
                {
                    Films.Add(movie);
                }
            }
            catch (HttpRequestException)
            {
                await UserDialogs.Instance.AlertAsync("Network Error");
            }
        }
示例#8
0
 public void RemoveAllFilms()
 {
     Films.Clear();
 }
示例#9
0
 private void ClearSearch()
 {
     Films.Clear();
     Persons.Clear();
     Reviews.Clear();
 }
示例#10
0
 public async Task LoadFilms()
 {
     Films.Clear();
     Films = await _filmEndpoint.GetFiveByTitle(SearchedPhrase);
 }