public IViewComponentResult Invoke(BasicBallotSearchViewModel model)
        {
            FilteredBallotViewModel result = null;

            result = new FilteredBallotViewModel()
            {
                FilteredBallots = _Context.Ballot
                                  .Where(b => string.IsNullOrWhiteSpace(model.BallotId) || b.BallotName == model.BallotId)
                                  .Where(b => model.ElectionDay == null || b.ElectionDay.Date == model.ElectionDay.Value.Date)
                                  .Where(b => model.BallotName == null || b.BallotName == model.BallotName)
                                  .Select(b => new FilteredBallotViewModel.BallotViewModel()
                {
                    BallotName  = b.BallotName,
                    ElectionDay = b.ElectionDay,
                    OfficeName  = b.OfficeName,
                    // use region, if null use district, if null use zipcode; one of them should be not null
                    Zone = b.RegionName ?? b.DistrictName ?? b.ZipCode.ToString()
                }),
                ActionViewComponent = model.ActionViewComponent
            };

            return(View(result));
        }
Beispiel #2
0
 public IActionResult SearchBallot(BasicBallotSearchViewModel model)
 {
     model.ActionViewComponent = "ViewBallot";
     return(ViewComponent(typeof(BallotViewComponent), model));
 }