Esempio n. 1
0
        public async Task <IActionResult> GetById(int locationID, string token)
        {
            if (!string.Equals(token, Constants.ANDROID_TOKEN))
            {
                throw new AuthenticationException("Bad token used.");
            }

            Location location = (Location)locationID;

            if (!Enum.IsDefined(typeof(Location), location) && !location.ToString().Contains(","))
            {
                throw new InvalidOperationException($"{locationID} is not an underlying value of the Location enumeration.");
            }

            List <TvItem> items = await _tvItemService.FetchActiveTvItemsAsync(location);

            await _eventService.AddHandShakeAsync(HttpContext.Connection.RemoteIpAddress.ToString(), WebClientLogType.ProgramRequest, location);

            return(new ObjectResult(items.Select(x => new MainContentResponse(x)).ToList()));
        }