public List <CeremonyViewModel> Search(CeremonyGuestSearchModel searchModel)
        {
            var query = _hContext.Ceremonies.Where(x => x.CeremonyGuests.Count() > 0).Include(x => x.CeremonyGuests).ThenInclude(x => x.Guest)
                        .Select(x => new CeremonyViewModel
            {
                Id             = x.Id,
                Title          = x.Title,
                CeremonyDate   = x.CeremonyDate.ToFarsi(),
                CeremonyGuests = MapGuests(x.CeremonyGuests)
            });

            //if (searchModel.GuestId != 0)
            //    query = query.Where(x => x.CeremonyGuests.GuestId == searchModel.GuestId);

            if (searchModel.CeremonyId != 0)
            {
                query = query.Where(x => x.Id == searchModel.CeremonyId);
            }

            return(query.OrderByDescending(x => x.Id).ToList());
        }
示例#2
0
 public void OnGet(CeremonyGuestSearchModel searchModel)
 {
     CeremonyGuests = _ceremonyGuestApplication.Search(searchModel);
     CeremoniesList = new SelectList(_ceremonyApplication.GetCeremonies(), "Id", "Title");
     GuestsList     = new SelectList(_guestApplication.GetGuests(), "Id", "FullName");
 }
示例#3
0
 public List <CeremonyViewModel> Search(CeremonyGuestSearchModel searchModel)
 {
     return(_ceremonyGuestRepository.Search(searchModel));
 }