Example #1
0
        // GET: TotalPitchings/Edit/5
        public void Edit(int PlayerID, int CoachId, int OpponentOfficialAtBats, int OpponentHits, int EarnedRunsScored, int InningsPitched, int StrikeOuts, int HomeRuns, int Walks, int BattersHBP, int PickOffAttempts, int PickOffs)
        {
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            //TotalPitching totalPitching = db.TotalPitchings.Find(id);
            //if (totalPitching == null)
            //{
            //    return HttpNotFound();
            //}
            //ViewBag.PlayerID = new SelectList(db.Players, "PlayerID", "FirstName", totalPitching.PlayerID);
            //return View(totalPitching);
            MorphingTables morph        = new MorphingTables();
            var            result       = from row in db.TotalPitchings where row.PlayerID == PlayerID select row;
            var            resultToUser = result.FirstOrDefault();

            resultToUser.PlayerID = PlayerID;
            resultToUser.CoachID  = CoachId;
            resultToUser.OpponentOfficialAtBats = morph.AddingStats(OpponentOfficialAtBats, resultToUser.OpponentOfficialAtBats);
            resultToUser.OpponentHits           = morph.AddingStats(OpponentHits, resultToUser.OpponentHits);
            resultToUser.EarnedRunsScored       = morph.AddingStats(EarnedRunsScored, resultToUser.EarnedRunsScored);
            resultToUser.InningsPitched         = morph.AddingStats(InningsPitched, resultToUser.InningsPitched);
            resultToUser.StrikeOuts             = morph.AddingStats(StrikeOuts, resultToUser.StrikeOuts);
            resultToUser.HomeRuns        = morph.AddingStats(HomeRuns, resultToUser.HomeRuns);
            resultToUser.Walks           = morph.AddingStats(Walks, resultToUser.Walks);
            resultToUser.BattersHBP      = morph.AddingStats(BattersHBP, resultToUser.BattersHBP);
            resultToUser.PickOffAttempts = morph.AddingStats(PickOffAttempts, resultToUser.PickOffAttempts);
            resultToUser.PickOffs        = morph.AddingStats(PickOffs, resultToUser.PickOffs);
            db.Entry(resultToUser).State = EntityState.Modified;
            db.SaveChanges();
            PitchStatsController pitch = new PitchStatsController();

            pitch.Edit(resultToUser.PlayerID, resultToUser.CoachID, resultToUser.OpponentOfficialAtBats, resultToUser.OpponentHits, resultToUser.EarnedRunsScored, resultToUser.InningsPitched, resultToUser.StrikeOuts, resultToUser.HomeRuns, resultToUser.Walks, resultToUser.BattersHBP, resultToUser.PickOffAttempts, resultToUser.PickOffs);
        }
Example #2
0
        public ActionResult Create([Bind(Include = "GameID,PlayerID,CoachID,OpponentOfficialAtBats,OpponentHits,EarnedRunsScored,InningsPitched,StrikeOuts,HomeRuns,Walks,BattersHBP,PickOffAttempts,PickOffs")] SubmitPitching submitPitching, TotalPitching stats)
        {
            if (ModelState.IsValid)
            {
                TotalPitchingsController total = new TotalPitchingsController();
                MorphingTables           morph = new MorphingTables();
                PitchStatsController     off   = new PitchStatsController();
                string user           = User.Identity.GetUserId();
                var    coachRow       = from row in db.Coaches where row.UserId == user select row;
                var    coachRowResult = coachRow.FirstOrDefault();
                submitPitching.CoachID = coachRowResult.CoachID;
                db.SubmitPitchings.Add(submitPitching);
                db.SaveChanges();
                foreach (var item in db.TotalPitchings)
                {
                    if (item.PlayerID == submitPitching.PlayerID)
                    {
                        total.Edit(submitPitching.PlayerID, submitPitching.CoachID, submitPitching.OpponentOfficialAtBats, submitPitching.OpponentHits, submitPitching.EarnedRunsScored, submitPitching.InningsPitched, submitPitching.StrikeOuts, submitPitching.HomeRuns, submitPitching.Walks, submitPitching.BattersHBP, submitPitching.PickOffAttempts, submitPitching.PickOffs);
                        return(RedirectToAction("Home", "Coaches"));
                    }
                }

                total.Create(submitPitching.PlayerID, submitPitching.CoachID, submitPitching.OpponentOfficialAtBats, submitPitching.OpponentHits, submitPitching.EarnedRunsScored, submitPitching.InningsPitched, submitPitching.StrikeOuts, submitPitching.HomeRuns, submitPitching.Walks, submitPitching.BattersHBP, submitPitching.PickOffAttempts, submitPitching.PickOffs, stats);
                return(RedirectToAction("Home", "Coaches"));
            }
            return(RedirectToAction("Home", "Coaches"));
        }
Example #3
0
        // GET: TotalPitchings/Create
        public void Create(int PlayerID, int CoachId, int OpponentOfficialAtBats, int OpponentHits, int EarnedRunsScored, int InningsPitched, int StrikeOuts, int HomeRuns, int Walks, int BattersHBP, int PickOffAttempts, int PickOffs, TotalPitching total)
        {
            total.PlayerID = PlayerID;
            total.CoachID  = CoachId;
            total.OpponentOfficialAtBats = OpponentOfficialAtBats;
            total.OpponentHits           = OpponentHits;
            total.EarnedRunsScored       = EarnedRunsScored;
            total.InningsPitched         = InningsPitched;
            total.StrikeOuts             = StrikeOuts;
            total.HomeRuns        = HomeRuns;
            total.Walks           = Walks;
            total.BattersHBP      = BattersHBP;
            total.PickOffAttempts = PickOffAttempts;
            total.PickOffs        = PickOffs;
            db.TotalPitchings.Add(total);
            db.SaveChanges();
            PitchStatsController pitch = new PitchStatsController();

            pitch.Create(total.PlayerID, total.CoachID, total.OpponentOfficialAtBats, total.OpponentHits, total.EarnedRunsScored, total.InningsPitched, total.StrikeOuts, total.HomeRuns, total.Walks, total.BattersHBP, total.PickOffAttempts, total.PickOffAttempts);
        }