Пример #1
0
        //反馈详情界面
        public IActionResult Index()
        {
            //34->Views/Home/Index.cshtml
            var viewModel = new HomeViewModel()
            {
                Feedbacks = _feedbackRepository.GetAllFeedbacks().ToList(),
                News      = _newRepository.GetAllNews().ToList(),
                Notices   = _noticeRepository.GetAllNotices().ToList(),
                Links     = _linkRepository.GetAllLinks().ToList()
            };

            return(View(viewModel));
        }
Пример #2
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
            }));
        }
Пример #3
0
        public async Task <IActionResult> ListAll()
        {
            var result = await _noticeRepository.GetAllNotices();

            if (result == null)
            {
                return(BadRequest(new ApiResult <dynamic>(new { Notice = ErrorCodes.CannotFindAnyNotice })));
            }
            return(Ok(new ApiResult <List <Notice> > {
                Result = result
            }));
        }
Пример #4
0
        public async Task <IActionResult> GetAsync([FromQuery] string search = null)
        {
            if (search == null)
            {
                List <L_Notice> noticesAll = await _noticeRepository.GetAllNotices();

                string json = JsonSerializer.Serialize(noticesAll);
                return(new ContentResult
                {
                    StatusCode = 200,
                    ContentType = "application/json",
                    Content = json
                });
                // (200 OK response, with the notes serialized in the response body -- instead of some view's HTML)
            }
            // TODO:
            throw new NotImplementedException();
            //L_Notice notice = _noticeRepository.
            //return Ok(notice);
        }
Пример #5
0
        public IActionResult GetAllNotices()
        {
            var result = _noticeRepository.GetAllNotices();

            return(Ok(result));
        }