Exemple #1
0
        public ActionResult Create([Bind(Include = "Game,PlayerID,CoachID,PlateAppearances,Singles,Doubles,Triples,HRs,Walks,HBP,Scrifices,OnByFeildersChoice,TotalBases,OnByInterference,DroppedThirdStrike,StolenBases,StolenBaseAttempts,SO,OtherBattingOuts,RBIs,RunsScored")] SubmitOffense subOffense, OffenseStats offenseStats, TotalOffense totalOff)
        {
            if (ModelState.IsValid)
            {
                string user           = User.Identity.GetUserId();
                var    coachRow       = from row in db.Coaches where row.UserId == user select row;
                var    coachRowResult = coachRow.FirstOrDefault();
                subOffense.CoachID = coachRowResult.CoachID;
                TotalOffensesController total = new TotalOffensesController();
                MorphingTables          morph = new MorphingTables();
                OffenseStatsController  off   = new OffenseStatsController();
                db.SubmitOffenses.Add(subOffense);
                db.SaveChanges();
                foreach (var item in db.GameOffenses)
                {
                    if (item.PlayerID == subOffense.PlayerID)
                    {
                        total.Edit(subOffense.PlayerID, subOffense.CoachID, subOffense.PlateAppearances, subOffense.Singles, subOffense.Doubles, subOffense.Triples, subOffense.HRs, subOffense.Walks, subOffense.HBP, subOffense.Scrifices, subOffense.OnByFeildersChoice, subOffense.TotalBases, subOffense.OnByInterference, subOffense.DroppedThirdStrike, subOffense.StolenBases, subOffense.StolenBaseAttempts, subOffense.SO, subOffense.OtherBattingOuts, subOffense.RBIs, subOffense.RunsScored);
                        return(RedirectToAction("Home", "Coaches"));
                    }
                }

                total.Create(subOffense.PlayerID, subOffense.CoachID, subOffense.PlateAppearances, subOffense.Singles, subOffense.Doubles, subOffense.Triples, subOffense.HRs, subOffense.Walks, subOffense.HBP, subOffense.Scrifices, subOffense.OnByFeildersChoice, subOffense.TotalBases, subOffense.OnByInterference, subOffense.DroppedThirdStrike, subOffense.StolenBases, subOffense.StolenBaseAttempts, subOffense.SO, subOffense.OtherBattingOuts, subOffense.RBIs, subOffense.RunsScored, totalOff);
                off.Create(totalOff.PlayerID, totalOff.CoachID, totalOff.PlateAppearances, totalOff.Singles, totalOff.Doubles, totalOff.Triples, totalOff.HRs, totalOff.Walks, totalOff.HBP, totalOff.Scrifices, totalOff.OnByFeildersChoice, totalOff.TotalBases, totalOff.OnByInterference, totalOff.DroppedThirdStrike, totalOff.StolenBases, totalOff.StolenBaseAttempts, totalOff.SO, totalOff.OtherBattingOuts, totalOff.RBIs, totalOff.RunsScored);
                return(RedirectToAction("Home", "Coaches"));
            }

            ViewBag.PlayerID = new SelectList(db.Players, "PlayerID", "FirstName", subOffense.PlayerID);
            return(View(subOffense));
        }
Exemple #2
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);
        }
Exemple #3
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"));
        }
Exemple #4
0
        // GET: DefenseStats/Create
        public void Create(int playerID, int CoachID, int position, int errors, int inningsPlayed, int putOuts, int assists)
        {
            DefenseHelpers helpers = new DefenseHelpers();
            MorphingTables morph   = new MorphingTables();

            defenseStats.PlayerID = playerID;
            defenseStats.CoachID  = CoachID;
            defenseStats.Position = position;
            defenseStats.Errors   = errors;
            defenseStats.IP       = inningsPlayed;
            defenseStats.PO       = putOuts;
            defenseStats.Assists  = assists;
            defenseStats.TC       = helpers.TotalChances(assists, putOuts, errors);
            defenseStats.FPCT     = helpers.FPCT(putOuts, assists, errors);
            db.Defense.Add(defenseStats);
            db.SaveChanges();
        }
Exemple #5
0
        // GET: TotalDefenses/Edit/5
        public void Edit(int playerID, int CoachID, int position, int errors, int inningsPlayed, int putOuts, int assists)
        {
            MorphingTables morph        = new MorphingTables();
            var            result       = from row in db.TotalDefenses where row.PlayerID == playerID select row;
            var            resultToUser = result.FirstOrDefault();

            resultToUser.PlayerID        = playerID;
            resultToUser.CoachID         = CoachID;
            resultToUser.Positions       = position;
            resultToUser.Errors          = morph.AddingStats(resultToUser.Errors, errors);
            resultToUser.InningsPlayed   = morph.AddingStats(resultToUser.InningsPlayed, inningsPlayed);
            resultToUser.PutOuts         = morph.AddingStats(resultToUser.PutOuts, putOuts);
            resultToUser.Assists         = morph.AddingStats(resultToUser.Assists, assists);
            db.Entry(resultToUser).State = EntityState.Modified;
            db.SaveChanges();
            DefenseStatsController newStats = new DefenseStatsController();

            newStats.Edit(resultToUser.PlayerID, resultToUser.CoachID, resultToUser.Positions, resultToUser.Errors, resultToUser.InningsPlayed, resultToUser.PutOuts, resultToUser.Assists);
        }
        // GET: GameOffenses/Edit/5
        public ActionResult Edit(int PlayerID, int CoachID, int PlateAppearances, int Singles, int Doubles, int Triples, int HRs, int Walks, int HBP, int Scrifices, int OnByFeildersChoice, int TotalBases, int OnByInterference, int DroppedThirdStrike, int StolenBases, int StolenBaseAttempts, int SO, int OtherBattingOuts, int RBIs, int RunsScored)
        {
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            //TotalOffense gameOffense = db.GameOffenses.Find(id);
            //if (gameOffense == null)
            //{
            //    return HttpNotFound();
            //}
            MorphingTables morph        = new MorphingTables();
            var            result       = from row in db.GameOffenses where row.PlayerID == PlayerID select row;
            var            resultToUser = result.FirstOrDefault();

            resultToUser.CoachID          = CoachID;
            resultToUser.PlayerID         = PlayerID;
            resultToUser.PlateAppearances = morph.AddingStats(PlateAppearances, resultToUser.PlateAppearances);
            resultToUser.Singles          = morph.AddingStats(Singles, resultToUser.Singles);
            resultToUser.Doubles          = morph.AddingStats(Doubles, resultToUser.Doubles);
            resultToUser.Triples          = morph.AddingStats(Triples, resultToUser.Triples);
            resultToUser.HRs                = morph.AddingStats(HRs, resultToUser.HRs);
            resultToUser.Walks              = morph.AddingStats(Walks, resultToUser.Walks);
            resultToUser.HBP                = morph.AddingStats(HBP, resultToUser.HBP);
            resultToUser.Scrifices          = morph.AddingStats(Scrifices, resultToUser.Scrifices);
            resultToUser.OnByFeildersChoice = morph.AddingStats(OnByFeildersChoice, resultToUser.OnByFeildersChoice);
            resultToUser.TotalBases         = morph.AddingStats(TotalBases, resultToUser.TotalBases);
            resultToUser.OnByInterference   = morph.AddingStats(OnByInterference, resultToUser.OnByInterference);
            resultToUser.DroppedThirdStrike = morph.AddingStats(DroppedThirdStrike, resultToUser.DroppedThirdStrike);
            resultToUser.StolenBases        = morph.AddingStats(StolenBases, resultToUser.StolenBases);
            resultToUser.StolenBaseAttempts = morph.AddingStats(StolenBaseAttempts, resultToUser.StolenBaseAttempts);
            resultToUser.SO = morph.AddingStats(SO, resultToUser.SO);
            resultToUser.OtherBattingOuts = morph.AddingStats(OtherBattingOuts, resultToUser.OtherBattingOuts);
            resultToUser.RBIs             = morph.AddingStats(RBIs, resultToUser.RBIs);
            resultToUser.RunsScored       = morph.AddingStats(RunsScored, resultToUser.RunsScored);
            db.Entry(resultToUser).State  = EntityState.Modified;
            db.SaveChanges();
            OffenseStatsController newStats = new OffenseStatsController();

            newStats.Edit(resultToUser.PlayerID, resultToUser.CoachID, resultToUser.PlateAppearances, resultToUser.Singles, resultToUser.Doubles, resultToUser.Triples, resultToUser.HRs, resultToUser.Walks, resultToUser.HBP, resultToUser.Scrifices, resultToUser.OnByFeildersChoice, resultToUser.TotalBases, resultToUser.OnByInterference, resultToUser.DroppedThirdStrike, resultToUser.StolenBases, resultToUser.StolenBaseAttempts, resultToUser.SO, resultToUser.OtherBattingOuts, resultToUser.RBIs, resultToUser.RunsScored);
            return(View());
        }