Пример #1
0
        public void ReplenishCacheFromSource()
        {
            List <Movie> movieData = movieDataSource.GetAllData();

            //List<Movie> movies = entityMapper.ConvertToLocalEntities(movieData);
            cache.ReplenishCacheFromSource(movieData);
        }
Пример #2
0
        public void InsertMovie()
        {
            MovieData moviedata = new MovieData();

            moviedata.Rating         = 1;
            moviedata.ReleaseDate    = DateTime.Now.Day;
            moviedata.Title          = "Insert Unit Test";
            moviedata.Genre          = "AA";
            moviedata.Classification = "A";
            moviedata.Cast           = new String[] { "Amitabh", "SriDevi" };
            int Count = movieDataSource.GetAllData().Count + 1;

            movie.InsertMovie(moviedata);
            int ActualCount = movieDataSource.GetAllData().Count;

            Assert.AreEqual(Count, ActualCount);
        }
Пример #3
0
        public IQueryable <MovieData> GetAllMovies()
        {
            var allMovies = _cacheHelper.GetFromCache <IQueryable <MovieData> >(ALL_MOVIES);

            if (allMovies == null)
            {
                allMovies = _dataSrc.GetAllData().AsQueryable();
                _cacheHelper.SaveTocache(ALL_MOVIES, allMovies, DateTime.Now.AddHours(24));
            }

            return(allMovies);
        }
Пример #4
0
 public void GetAllData()
 {
     var movieDataSource = new MovieDataSource();
     var allMovies = movieDataSource.GetAllData();
     Assert.IsTrue(allMovies.Any());
 }
Пример #5
0
        /// <summary>
        /// Get all the movies data present in existing database
        /// <para>No Paramters Required</para>
        /// </summary>
        /// <returns>All Movies in Genric list of MovieData</returns>
        public List <MovieData> InternalGetMovies()
        {
            List <MovieData> movieData = movieDataSource.GetAllData();

            return(movieData);
        }
        /// <summary>
        ///     Gets all movies from data source.
        /// </summary>
        /// <returns>List of MovieDto</returns>
        public List <MovieDto> GetAllMovies()
        {
            var movies = _dataSource.GetAllData();

            return(movies.Select(m => m.ToDto()).ToList());
        }
Пример #7
0
        public IHttpActionResult GetAllData(MovieDataModel model)
        {
            try
            {
                int skip = (model.page * model.pageSize) - model.pageSize;
                int take = model.pageSize;

                IEnumerable <MovieData> data = _dataSource.GetAllData();

                if (!string.IsNullOrEmpty(model.Search))
                {
                    data = data.Where(x => x.MovieId.ToString() == model.Search

                                      || x.Title.Contains(model.Search)

                                      || x.Genre.Contains(model.Search)

                                      || x.Classification.Contains(model.Search)


                                      || x.ReleaseDate.ToString() == model.Search

                                      || x.Rating.ToString() == model.Search

                                      );
                }


                if (model.OrderBy == OrderBy.Asc)
                {
                    if (model.orderbyCol == SortType.MovieId)
                    {
                        data = data.OrderBy(x => x.MovieId);
                    }

                    if (model.orderbyCol == SortType.Title)
                    {
                        data = data.OrderBy(x => x.Title);
                    }

                    if (model.orderbyCol == SortType.Genre)
                    {
                        data = data.OrderBy(x => x.Genre);
                    }

                    if (model.orderbyCol == SortType.Classification)
                    {
                        data = data.OrderBy(x => x.Classification);
                    }


                    if (model.orderbyCol == SortType.ReleaseDate)
                    {
                        data = data.OrderBy(x => x.ReleaseDate);
                    }


                    if (model.orderbyCol == SortType.Rating)
                    {
                        data = data.OrderBy(x => x.Rating);
                    }
                }
                else
                {
                    if (model.orderbyCol == SortType.MovieId)
                    {
                        data = data.OrderByDescending(x => x.MovieId);
                    }

                    if (model.orderbyCol == SortType.Title)
                    {
                        data = data.OrderByDescending(x => x.Title);
                    }

                    if (model.orderbyCol == SortType.Genre)
                    {
                        data = data.OrderByDescending(x => x.Genre);
                    }

                    if (model.orderbyCol == SortType.Classification)
                    {
                        data = data.OrderByDescending(x => x.Classification);
                    }


                    if (model.orderbyCol == SortType.ReleaseDate)
                    {
                        data = data.OrderByDescending(x => x.ReleaseDate);
                    }


                    if (model.orderbyCol == SortType.Rating)
                    {
                        data = data.OrderByDescending(x => x.Rating);
                    }
                }


                var totalCount = data.Count();
                var retData    = data.Skip(skip).Take(take);
                return(Ok(new ArrayList {
                    retData, totalCount
                }));
            }
            catch (Exception ex)
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)));
            }
        }