Beispiel #1
0
        public async Task <IActionResult> Index([FromQuery] HomeFilterQuery query)
        {
            var notices = new List <Notice>();

            if (string.IsNullOrEmpty(query.Gender) && string.IsNullOrEmpty(query.District))
            {
                notices = await _noticeRepository.GetAllNotices();
            }
            else
            {
                notices = await _noticeRepository.GetNotices(query.Gender, query.District);
            }

            var result = new List <NoticeShortcutVm>();

            foreach (var notice in notices)
            {
                result.Add(new NoticeShortcutVm
                {
                    Id                  = notice.NoticeId,
                    Name                = notice.Name,
                    Surname             = notice.Surname,
                    DateOfDisappearance = notice.DateOfDisappearance.ToShortDateString(),
                    Gender              = notice.Gender,
                    Age                 = notice.Age,
                    LastSeenPlace       = notice.LastSeenPlace,
                    District            = notice.District
                });
            }

            return(Ok(new ApiResult <List <NoticeShortcutVm> > {
                Result = result
            }));
        }
        public async Task <ActionResult> Index()
        {
            var model = await _noticeRepository.GetNotices();

            return(View(model));
        }