示例#1
0
        public void Create(FantasyFootballBdo fantasyFootballBdo)
        {
            var utcNow = DateTime.UtcNow;

            var seasonEntity = SeasonsRepository.Get(utcNow);

            if (seasonEntity == null)
            {
                throw new Exception($"There is no Fantasy Football Season covering the Date = {utcNow:yyyy-MMM-dd}.");
            }

            _seasonId = seasonEntity.SeasonId;

            _weekOffset = DateTimeHelper.GetWeekOffset(seasonEntity, utcNow);

            var teamEntity = TeamsRepository.GetFirstOrDefault(entity => (entity.SeasonId == _seasonId) && (entity.WeekOffset == _weekOffset));

            if (teamEntity != null)
            {
                throw new Exception($"There already exists a Weekly Results Set covering the Date = {utcNow:yyyy-MMM-dd}, otherwise known as Season Id = {_seasonId} and Week Offset = {_weekOffset}.");
            }

            _fantasyFootballBdo = fantasyFootballBdo;

            foreach (var teamBdoPair in _fantasyFootballBdo.Teams)
            {
                AddTeam(teamBdoPair.Value);
            }
        }
        public void OnGet()
        {
            var lastSeasons = SeasonsRepository
                              .GetAll()
                              .OrderByDescending(entity => entity.SeasonId)
                              .ToList();

            var beginDateTimeUtc = DateTime.UtcNow;

            LastSeasons = lastSeasons;
        }
        public string Create()
        {
            string resultFile = null;

            var utcNow = DateTime.UtcNow;

            var seasonEntity = SeasonsRepository.Get(utcNow);

            if (seasonEntity == null)
            {
                throw new Exception($"There is no Fantasy Football Season covering the Date = {utcNow:yyyy-MMM-dd}.");
            }

            _seasonId = seasonEntity.SeasonId;

            _weekOffset = DateTimeHelper.GetWeekOffset(seasonEntity, utcNow);

            var firstResultsSet = TeamsRepository.GetFirstOrDefault(entity => (entity.SeasonId == _seasonId) && (entity.WeekOffset == _weekOffset));

            if (firstResultsSet == null)
            {
                throw new Exception($"There is no Weekly Results Set covering the Date = {utcNow:yyyy-MMM-dd}, otherwise known as Season Id = {_seasonId} and Week Offset = {_weekOffset}.");
            }

            _document = new Document();

            var teamEntities = TeamsRepository
                               .GetAll(_seasonId, _weekOffset);

            foreach (var teamEntity in teamEntities)
            {
                AddTeam(teamEntity);
            }

            HeaderFooter footer          = _document.Sections[0].HeadersFooters.Footer;
            Paragraph    footerParagraph = footer.AddParagraph();
            var          textRange       = footerParagraph.AppendText($"Season Id = {_seasonId} : Week Offset = {_weekOffset} : Page ");

            textRange.CharacterFormat.FontName = "Calibri";
            textRange = footerParagraph.AppendField("page number", FieldType.FieldPage);
            textRange.CharacterFormat.FontName         = "Calibri";
            footerParagraph.Format.HorizontalAlignment = HorizontalAlignment.Center;

            resultFile = $"Fantasy Football Assistant - {DateTime.UtcNow:yyyy-MMM-dd}.docx";

            _document.SaveToFile($"wwwroot\\{resultFile}", FileFormat.Docx2013);

            return(resultFile);
        }
        public void OnGet(int seasonId)
        {
            SeasonId = seasonId;

            var seasonEntity = SeasonsRepository.Get(seasonId);

            Season = seasonEntity;

            if (seasonEntity != null)
            {
                Description      = seasonEntity.Description;
                BeginDateTimeUtc = seasonEntity.BeginDateTimeUtc;
                EndDateTimeUtc   = seasonEntity.EndDateTimeUtc;
            }
        }
示例#5
0
        public IActionResult OnPost(string confirm, int seasonId)
        {
            IsGet = false;

            if (confirm == "Yes")
            {
                var seasonEntity = SeasonsRepository.Get(seasonId);

                if (seasonEntity != null)
                {
                    SeasonsRepository.Delete(seasonEntity);
                    SeasonsRepository.SaveChanges();
                }
            }

            return(RedirectToPage("/web/Index"));
        }
示例#6
0
        public IActionResult OnPost(string action)
        {
            IsGet = false;

            if (action == "Create")
            {
                // TODO: Check that the new Season does not Exist Already nor is it Active.

                var seasonEntity = new SeasonEntity()
                {
                    Description        = Description,
                    BeginDateTimeUtc   = BeginDateTimeUtc.Date,
                    EndDateTimeUtc     = EndDateTimeUtc.Date.AddDays(1).AddMilliseconds(-1),
                    CreatedDateTimeUtc = DateTime.UtcNow
                };

                SeasonsRepository.Create(seasonEntity);
                SeasonsRepository.SaveChanges();
            }

            return(RedirectToPage("/web/Index"));
        }
        public IActionResult OnPost(string action, int seasonId)
        {
            IsGet = false;

            // TODO: Check that the new Season Exists Already and is Active.

            if (action == "Update")
            {
                var seasonEntity = SeasonsRepository.Get(seasonId);

                if (seasonEntity != null)
                {
                    seasonEntity.Description        = Description;
                    seasonEntity.EndDateTimeUtc     = EndDateTimeUtc.Date.AddDays(1).AddMilliseconds(-1);
                    seasonEntity.UpdatedDateTimeUtc = DateTime.UtcNow;

                    SeasonsRepository.Update(seasonEntity);
                    SeasonsRepository.SaveChanges();
                }
            }

            return(RedirectToPage("/web/Index"));
        }
示例#8
0
        public void OnGet(int seasonId)
        {
            SeasonId = seasonId;

            Season = SeasonsRepository.Get(seasonId);
        }