コード例 #1
0
 public MainViewModel()
 {
     PlaysCriteria = new PlaysSearchingCriteria();
     PeopleCriteria = new PeopleSearchingCriteria();
     AwardsCriteria = new AwardsSearchingCriteria();
 }
コード例 #2
0
 public List<Play> SearchPlays(PlaysSearchingCriteria criteria, int pageNr, int pageAmount)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
        public ListResponse<PlayTitleDTO> SearchPlaysTitles(PlaysSearchingCriteria criteria, int pageNr, int pageAmount)
        {
            using (var context = new AF_Context())
            {
                try
                {
                    var skip = pageAmount * (pageNr - 1);
                    var query = (from p in context.Plays select p);
                    if (criteria.FestivalIdFilter != null)
                        query = query.Where(p => p.FestivalId == criteria.FestivalIdFilter);
                    if (!String.IsNullOrEmpty(criteria.Author))
                        query = query.Where(p => p.Author.Contains(criteria.Author));
                    if (!String.IsNullOrEmpty(criteria.Title))
                        query = query.Where(p => p.Title.Contains(criteria.Title));
                    if (!String.IsNullOrEmpty(criteria.Motto))
                        query = query.Where(p => p.Motto.Contains(criteria.Motto));

                    List<PlayTitleDTO> tmp = new List<PlayTitleDTO>();
                    foreach (Play pla in (query.OrderBy(p => p.FestivalId)
                        .ThenBy(p => p.Day)
                        .ThenBy(p => p.Order)
                        .Skip(skip)
                        .Take(pageAmount)))
                    {
                        var newPlayDto = new PlayTitleDTO()
                        {
                            PlayId = pla.PlayId,
                            Title = pla.Title,
                        };
                        tmp.Add(newPlayDto);
                    }
                    return (new ListResponse<PlayTitleDTO>(tmp));
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }