Ejemplo n.º 1
0
        public async Task <IEnumerable <CreateProjectionFilterResultModel> > FilterProjectionsByMovieName(string searchData)
        {
            var data = await _projectionsRepository.FilterProjectionsByMovieTitle(searchData);

            List <CreateProjectionFilterResultModel> result = new List <CreateProjectionFilterResultModel>();

            if (data == null)
            {
                result.Add(new CreateProjectionFilterResultModel
                {
                    IsSuccessful = false,
                    ErrorMessage = Messages.PROJECTION_SEARCH_ERROR
                });
                return(result);
            }
            var n = data.Count();


            if (data.Count() == 0)
            {
                result.Add(new CreateProjectionFilterResultModel
                {
                    IsSuccessful = true,
                    ErrorMessage = Messages.PROJECTION_SEARCH_NORESULT,
                    Projection   = new ProjectionDomainFilterModel
                    {
                        AditoriumName = "Auditorium not found",
                        MovieTitle    = "Movie not found.",
                        CinemaName    = "Cinema not found",
                    }
                });
                return(result);
            }

            foreach (var item in data)
            {
                CreateProjectionFilterResultModel model = new CreateProjectionFilterResultModel
                {
                    IsSuccessful = true,
                    ErrorMessage = Messages.PROJECTION_SEARCH_SUCCESSFUL,
                    Projection   = new ProjectionDomainFilterModel
                    {
                        AditoriumName  = item.Auditorium.Name,
                        MovieTitle     = item.Movie.Title,
                        ProjectionTime = item.DateTime,
                        CinemaName     = item.Auditorium.Cinema.Name
                    }
                };
                result.Add(model);
            }
            return(result);
        }