Exemplo n.º 1
0
        public bool CreateReceivingStats(NFLPlayerStats_ReceivingCreate model)
        {
            var entity =
                new NFLPlayerStats_Receiving()
            {
                Targets    = model.Targets,
                Receptions = model.Receptions,
                Touchdowns = model.Touchdowns,
                PlayerId   = model.playerid,
                Yards      = model.Yards
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.NFLPlayer_Receiving.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(NFLPlayerStats_ReceivingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateReceivingService();

            if (service.CreateReceivingStats(model))
            {
                TempData["SaveResult"] = "Receiving stats addded";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Receiving stats could not be added");
            return(View(model));
        }