Beispiel #1
0
        public Data.Fight SaveToDatabase(FightOptions options, int fighter1Id, int fighter2Id, int plan1Id, int plan2Id, string parseText)
        {
            {
                WeebulEntities entities = Data.DataHelpers.Entities;
                entities.Fights.Load();
                FightOption o = entities.FightOptions.Create();
                o.CutMultiplier  = options.CutFactor;
                o.Luck           = options.LuckAmount;
                o.NumberOfRounds = options.TotalRounds;
                o.WeightClass    = (int)options.WeightClass;
                o = entities.FightOptions.Add(o);
                int        upd = entities.SaveChanges();
                Data.Fight f   = entities.Fights.Create();
                f.Fighter1Id     = fighter1Id;
                f.Fighter2Id     = fighter2Id;
                f.Fighter1PlanId = plan1Id;
                f.Fighter2PlanId = plan2Id;

                f.Fighter1Score = this.Fighter1Score;
                f.Fighter2Score = this.Fighter2Score;

                f.NumberOfRounds = this.Result.Rounds;
                f.OptionsId      = o.OptionsId;

                bool?fighter1Win = null;

                if (this.Result.Outcome == FightOutcome.Win)
                {
                    fighter1Win = true;
                }
                else if (this.Result.Outcome == FightOutcome.Loss)
                {
                    fighter1Win = false;
                }
                f.Fighter1Win = fighter1Win;
                f.IsParsed    = true;
                f.ResultType  = (int)this.Result.ResultType;

                f            = entities.Fights.Add(f);
                f.Date       = DateTime.Now;
                f.ParseText  = parseText;
                f.TkoCut     = this.Result.TkoCut;
                f.CutLevelF1 = this.RoundResults.Last().Fighter1Round.CutLevel;
                f.CutLevelF2 = this.RoundResults.Last().Fighter2Round.CutLevel;
                entities.SaveChanges();
                foreach (Round rr in this.RoundResults)
                {
                    rr.CreateToDatabase(f.FightId);
                }
                entities.SaveChanges();
                return(f);
            }
        }
Beispiel #2
0
        public Data.JudgeRound CreateInDatabase(int roundId)
        {
            WeebulEntities entities = DataHelpers.Entities;

            Data.JudgeRound dataRound = entities.JudgeRounds.Create();

            dataRound.RoundId       = roundId;
            dataRound.JudgeNumber   = JudgeNumber;
            dataRound.Fighter1Score = Score.Fighter1Score;
            dataRound.Fighter2Score = Score.Fighter2Score;
            dataRound = entities.JudgeRounds.Add(dataRound);
            return(dataRound);
        }
Beispiel #3
0
        public static Dictionary <CutBase, int> LoadIDDictionary()
        {
            Dictionary <CutBase, int> ret = new Dictionary <Model.CutBase, int>();

            WeebulEntities entities = DataHelpers.Entities;

            entities.Cuts.Load();
            foreach (Data.Cut cut in entities.Cuts)
            {
                CutBase cb = new Model.CutBase((CutType)cut.CutType, (CutSeverity)cut.Severity);
                ret.Add(cb, cut.CutId);
            }
            return(ret);
        }
Beispiel #4
0
        public Data.FighterRound CreateInDatabase(int roundId, bool isFighter1)
        {
            WeebulEntities entities = DataHelpers.Entities;

            Data.FighterRound dataRound = entities.FighterRounds.Create();
            dataRound.RoundId    = roundId;
            dataRound.IsFighter1 = isFighter1;
            CopyToDataRound(dataRound);
            Tactic t = this.Tactics.GetDataTactic();

            dataRound.TacticsId = t.TacticsId;
            Data.FighterRound saved = entities.FighterRounds.Add(dataRound);
            entities.SaveChanges();
            SaveCuts(saved.FRID);
            entities.SaveChanges();
            return(saved);
        }
Beispiel #5
0
        public Data.Round CreateToDatabase(int fightId)
        {
            WeebulEntities entities = DataHelpers.Entities;

            Data.Round r = entities.Rounds.Create();

            r.FightId       = fightId;
            r.Fighter1Score = this.Fighter1Score;
            r.Fighter2Score = this.Fighter2Score;
            r.ResultType    = (int)this.ResultType;
            r.RoundNumber   = this.RoundNumber;
            r = entities.Rounds.Add(r);
            entities.SaveChanges();
            this.Fighter1Round.CreateInDatabase(r.RoundId, true);
            this.Fighter2Round.CreateInDatabase(r.RoundId, false);
            if (JudgeRounds != null && JudgeRounds.Count > 0)
            {
                foreach (JudgeRound jr in this.JudgeRounds)
                {
                    jr.CreateInDatabase(r.RoundId);
                }
            }
            return(r);
        }