Esempio n. 1
0
        public IHttpActionResult Post(TeSeasonStatCreate season)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            TeSeasonStatService service = new TeSeasonStatService();

            if (!service.TeCreateSeason(season))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Esempio n. 2
0
        //CREATE
        public bool TeCreateSeason(TeSeasonStatCreate season)
        {
            var playerSeason = new SeasonStatTe()
            {
                PlayerId        = season.PlayerId,
                Year            = season.Year,
                Receptions      = season.Receptions,
                Targets         = season.Targets,
                Drops           = season.Drops,
                ReceivingYards  = season.ReceivingYards,
                YardsAfterCatch = season.YardsAfterCatch,
                Touchdowns      = season.Touchdowns,
                PlayerNumber    = season.PlayerNumber,
                Team            = season.Team
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.TeSeasonStats.Add(playerSeason);
                return(ctx.SaveChanges() == 1);
            }
        }