public Pagination <ShowGetDTO> Execute(ShowSearch request) { var data = Context.Shows.AsQueryable(); if (request.ShowTitle != null) { data = data.Where(s => s.Title.ToLower().Contains(request.ShowTitle.ToLower()) && !s.IsDeleted); } var totalCount = data.Count(); data = data.Skip(request.PageNumber * request.PerPage - request.PerPage).Take(request.PerPage); // offset = pageNumber * perPage - perPage // limit = perPage var totalPages = (int)Math.Ceiling((double)totalCount / request.PerPage); return(new Pagination <ShowGetDTO> { CurrentPage = request.PageNumber, PagesCount = totalPages, TotalCount = totalCount, Intel = data.Select(s => new ShowGetDTO { Body = s.Body, About = s.About, Dislikes = s.Dislikes, Likes = s.Likes, Title = s.Title }) }); }
// GET: Shows public ActionResult Index([FromQuery] ShowSearch value) { var all = new ShowDTOModel(); all.Shows = getShowsCommand.Execute(value); return(View(all)); }
public SearchController(EpisodeSearch episodeSearch, ShowSearch showSearch, IShowRepository showRepo, ILogger <SearchController> logger) { _episodeSearch = episodeSearch; _showSearch = showSearch; _showRepo = showRepo; _logger = logger; }
public Pagination <ShowDTO> Execute(ShowSearch request) { var data = Context.Shows.AsQueryable(); if (request.ShowTitle != null) { var wanted = request.ShowTitle.ToLower(); data = data.Where(s => s.ShowTitle.ToLower().Contains(wanted) && s.Deleted == false); } if (request.OnlyActive.HasValue) { data = data.Where(s => s.Deleted != request.OnlyActive); } if (request.CategoryId.HasValue) { data = data.Where(s => s.CategoryId == request.CategoryId && s.Deleted == false); } if (request.ActorFirstName != null) { data = data.Where(asc => asc.ActorShows.Any(a => a.Actor.ActorFirstName.ToLower() .Contains(request.ActorFirstName.ToLower()) && asc.Deleted == false)); } if (request.ActorLastName != null) { data = data.Where(asc => asc.ActorShows.Any(a => a.Actor.ActorFirstName.ToLower() .Contains(request.ActorLastName.ToLower()) && asc.Deleted == false)); } var totalCount = data.Count(); data = data.Include(sa => sa.ActorShows).ThenInclude(s => s.Actor) .Skip((request.PageNumber - 1) * request.PerPage).Take(request.PerPage); var totalPages = (int)Math.Ceiling((double)totalCount / request.PerPage); var res = new Pagination <ShowDTO> { CurrentPage = request.PageNumber, TotalCount = totalCount, PagesCount = totalPages, Data = data.Select(s => new ShowDTO { Id = s.Id, ActorIds = s.ActorShows.Select(a => a.ActorId), CategoryId = s.CategoryId, ShowPicturePath = s.ShowPicturePath, ShowText = s.ShowText, ShowTitle = s.ShowTitle, ShowYear = s.ShowYear }) }; return(res); }
// поиск анимация показа\скрытия private void ShowSearchPanel(object sender, RoutedEventArgs e) { if (Search.Visibility == Visibility.Collapsed) { Search.Visibility = Visibility.Visible; ShowSearch.Begin(); } else { HideSearch.Begin(); } }
public ActionResult Shows(string SearchByShow) { List <ShowSearch> data; using (var webClient = new System.Net.WebClient() { Encoding = System.Text.Encoding.UTF8 }) //UTF8 used so that I can properly handle certain symbols that are used in the information returned in the json object { var json = webClient.DownloadString("http://api.tvmaze.com/search/shows?q=" + HttpUtility.UrlEncode(SearchByShow)); data = ShowSearch.FromJson(json); } return(View(data)); }
public IEnumerable <ShowDTO> Execute(ShowSearch request) { var data = Context.Shows.AsQueryable(); if (request.ShowTitle != null) { var wanted = request.ShowTitle.ToLower(); data = data.Where(s => s.ShowTitle.ToLower().Contains(wanted) && s.Deleted == false); } if (request.OnlyActive.HasValue) { data = data.Where(s => s.Deleted != request.OnlyActive); } if (request.CategoryId.HasValue) { data = data.Where(s => s.CategoryId == request.CategoryId && s.Deleted == false); } if (request.ActorFirstName != null) { data = data.Where(asc => asc.ActorShows.Any(a => a.Actor.ActorFirstName.ToLower() .Contains(request.ActorFirstName.ToLower()) && asc.Deleted == false)); } if (request.ActorLastName != null) { data = data.Where(asc => asc.ActorShows.Any(a => a.Actor.ActorFirstName.ToLower() .Contains(request.ActorLastName.ToLower()) && asc.Deleted == false)); } return(data.Include(d => d.ActorShows).ThenInclude(p => p.Actor).Select(s => new ShowDTO { Id = s.Id, ActorIds = s.ActorShows.Select(a => a.ActorId), CategoryId = s.CategoryId, ShowPicturePath = s.ShowPicturePath, ShowText = s.ShowText, ShowTitle = s.ShowTitle, ShowYear = s.ShowYear })); }
public IActionResult Get([FromQuery] ShowSearch shows) { var data = _getShowsInterface.Execute(shows); return(Ok(data)); }
public ActionResult Get([FromQuery] ShowSearch shows) => Ok(getShowsCommand.Execute(shows));