Exemplo n.º 1
0
        public IActionResult Index(int year)
        {
            Func <string, IDictionary <string, object>, IEnumerable <WorldCupFsharpRepositoryModule.WorldCupDto> >
            readDataFunc = (s, p) => _postgresConnection.readData <WorldCupFsharpRepositoryModule.WorldCupDto>(s,
                                                                                                               p);

            var readData = FuncConvert.FromFunc(readDataFunc);

            var worldCupFsharpOption = WorldCupFsharpRepositoryModule.findByYear(readData, YearModule.create(year));

            if (worldCupFsharpOption.HasValue())
            {
                var worldCupFsharp = worldCupFsharpOption.Value;

                var worldCupVm = new WorldCupVm
                {
                    Year   = YearModule.value(worldCupFsharp.Year),
                    Host   = WorldCupHostModule.value(worldCupFsharp.Host),
                    Winner = CountryModule.value(worldCupFsharp.Winner)
                };

                return(Content(JsonConvert.SerializeObject(worldCupVm), "application/json"));
            }

            return(NotFound());
        }