コード例 #1
0
        public IActionResult Index()
        {
            var referees          = refereeService.GetAll();
            var refereeViewModels = referees.Select(r => new RefereeViewModel
            {
                Id          = r.Id,
                Name        = r.Name,
                BirthDate   = r.BirthDate,
                CountryId   = r.Country.Id,
                CountryName = r.Country.Name
            });

            return(View(refereeViewModels));
        }
コード例 #2
0
        public HttpResponseMessage GetReferees()
        {
            IList <Referee> refereeList = new List <Referee>();

            if (HttpRuntime.Cache["Referee"] != null)
            {
                refereeList = HttpRuntime.Cache["Referee"] as List <Referee>;
            }
            else
            {
                refereeList = _refereeService.GetAll().ToList();
                SqlCacheHelper.FetchFromDb("Referee", refereeList);
            }

            if (refereeList.Count == 0)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, refereeList));
        }