示例#1
0
        public override ActionResult Index(ContentModel contentModel)
        {
            var model = new StyleGuide(contentModel?.Content)
            {
                Metadata = new ViewMetadata {
                    PageTitle = contentModel.Content.Name
                },
                GoogleMapsApiKey = _apiKeyProvider.GetApiKey("GoogleMaps")
            };

            return(CurrentTemplate(model));
        }
        public async override Task <ActionResult> Index(ContentModel contentModel)
        {
            if (contentModel is null)
            {
                throw new System.ArgumentNullException(nameof(contentModel));
            }

            var model = new MatchLocationViewModel(contentModel.Content, Services?.UserService)
            {
                MatchLocation    = await _matchLocationDataSource.ReadMatchLocationByRoute(Request.RawUrl, false).ConfigureAwait(false),
                GoogleMapsApiKey = _apiKeyProvider.GetApiKey("GoogleMaps")
            };


            if (model.MatchLocation == null)
            {
                return(new HttpNotFoundResult());
            }
            else
            {
                model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.MatchLocation);

                model.Metadata.PageTitle = "Edit " + model.MatchLocation.NameAndLocalityOrTown();

                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = Constants.Pages.MatchLocations, Url = new Uri(Constants.Pages.MatchLocationsUrl, UriKind.Relative)
                });
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = model.MatchLocation.NameAndLocalityOrTownIfDifferent(), Url = new Uri(model.MatchLocation.MatchLocationRoute, UriKind.Relative)
                });

                return(CurrentTemplate(model));
            }
        }
        public async override Task <ActionResult> Index(ContentModel contentModel)
        {
            if (contentModel is null)
            {
                throw new ArgumentNullException(nameof(contentModel));
            }

            var model = new SeasonViewModel(contentModel.Content, Services?.UserService)
            {
                Season           = await _seasonDataSource.ReadSeasonByRoute(Request.RawUrl, false).ConfigureAwait(false),
                GoogleMapsApiKey = _apiKeyProvider.GetApiKey("GoogleMaps")
            };

            if (model.Season == null)
            {
                return(new HttpNotFoundResult());
            }
            else
            {
                var the = model.Season.Competition.CompetitionName.StartsWith("THE ", StringComparison.OrdinalIgnoreCase);
                model.Metadata.PageTitle   = $"Map of teams in {(the ? string.Empty : "the ")}{model.Season.SeasonFullNameAndPlayerType()}";
                model.Metadata.Description = model.Season.Description();

                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = Constants.Pages.Competitions, Url = new Uri(Constants.Pages.CompetitionsUrl, UriKind.Relative)
                });
                model.Breadcrumbs.Add(new Breadcrumb {
                    Name = model.Season.Competition.CompetitionName, Url = new Uri(model.Season.Competition.CompetitionRoute, UriKind.Relative)
                });

                return(CurrentTemplate(model));
            }
        }
示例#4
0
        public string GetApiKey(HttpContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(_apiKeyProvider.GetApiKey(context));
        }
示例#5
0
        public override Task <ActionResult> Index(ContentModel contentModel)
        {
            if (contentModel is null)
            {
                throw new System.ArgumentNullException(nameof(contentModel));
            }

            var model = new TeamsViewModel(contentModel.Content, Services?.UserService)
            {
                GoogleMapsApiKey = _apiKeyProvider.GetApiKey("GoogleMaps")
            };

            model.Metadata.PageTitle = "Map of " + Constants.Pages.Teams.ToLower(CultureInfo.CurrentCulture);

            return(Task.FromResult(CurrentTemplate(model)));
        }
        public async Task InvokeAsync(HttpContext context, IApiKeyProvider apiKeyProvider)
        {
            if (!context.Request.Headers.TryGetValue(ApiKeyHeaderName, out var extractedApiKey))
            {
                context.Response.StatusCode = 401;
                await context.Response.WriteAsync("Please provide ApiKey in Authorization header");

                return;
            }

            if (!extractedApiKey.Equals(apiKeyProvider.GetApiKey()))
            {
                context.Response.StatusCode = 401;
                await context.Response.WriteAsync("Wrong ApiKey");

                return;
            }

            await _next(context);
        }
示例#7
0
        public override Task <ActionResult> Index(ContentModel contentModel)
        {
            if (contentModel is null)
            {
                throw new System.ArgumentNullException(nameof(contentModel));
            }

            var model = new MatchLocationViewModel(contentModel.Content, Services?.UserService)
            {
                MatchLocation    = new MatchLocation(),
                GoogleMapsApiKey = _apiKeyProvider.GetApiKey("GoogleMaps")
            };

            model.IsAuthorized = _authorizationPolicy.IsAuthorized(model.MatchLocation);

            model.Metadata.PageTitle = "Add a ground or sports centre";

            model.Breadcrumbs.Add(new Breadcrumb {
                Name = Constants.Pages.MatchLocations, Url = new Uri(Constants.Pages.MatchLocationsUrl, UriKind.Relative)
            });

            return(Task.FromResult(CurrentTemplate(model)));
        }