Exemplo n.º 1
0
 public Creature(Dictionary <string, object> NamedRange)
 {
     Id             = (NamedRange.ContainsKey("Id")? NamedRange["Id"].ToString().AsInt(): -1);
     SpeciesId      = NamedRange["SpeciesId"].ToString().AsInt();
     EvolutionId    = NamedRange["EvolutionId"].ToString().AsInt();
     EvolutionStage = NamedRange["EvolutionStage"].ToString().AsInt();
     NameEn         = NamedRange["NameEn"].ToString();
     NameFr         = NamedRange["NameFr"].ToString();
     BaseRank       = NamedRange["BaseRank"].ToString().AsInt();
     HP             = NamedRange["HP"].ToString().AsInt();
     ATK            = NamedRange["ATK"].ToString().AsInt();
     DEF            = NamedRange["DEF"].ToString().AsInt();
     SPD            = NamedRange["SPD"].ToString().AsInt();
     CRIT           = NamedRange["CRIT"].ToString().AsInt();
     CRITD          = NamedRange["CRITD"].ToString().AsInt();
     ACC            = NamedRange["ACC"].ToString().AsInt();
     RES            = NamedRange["RES"].ToString().AsInt();
     Element        = new Element(NamedRange["ElementId"].ToString().AsInt());
     Role           = new Role(NamedRange["RoleId"].ToString().AsInt());
     Skills         = new List <Skill>()
     {
         SkillRepository.GetSkillById((NamedRange.ContainsKey("Spell1Id")? NamedRange["Spell1Id"].ToString().AsInt(): -1)),
         SkillRepository.GetSkillById((NamedRange.ContainsKey("Spell1AId")? NamedRange["Spell1AId"].ToString().AsInt(): -1)),
         SkillRepository.GetSkillById((NamedRange.ContainsKey("Spell1BId")? NamedRange["Spell1BId"].ToString().AsInt(): -1)),
         SkillRepository.GetSkillById((NamedRange.ContainsKey("Spell2Id")? NamedRange["Spell2Id"].ToString().AsInt(): -1)),
         SkillRepository.GetSkillById((NamedRange.ContainsKey("Spell3Id")? NamedRange["Spell3Id"].ToString().AsInt(): -1))
     };
 }
Exemplo n.º 2
0
        private List <EvaluationDetail> getEvaluationDetailsByEvaluationId(int evaluationId)
        {
            var res = new List <EvaluationDetail>();

            var skillRepository = new SkillRepository();

            var query = "SELECT [ED].[Id], " +
                        "       [ED].[EvaluationId]," +
                        "       [ED].[SkillId]," +
                        "       [ED].[Expertise] " +
                        "FROM [dbo].[EvaluationDetail] AS [ED] " +
                        "WHERE [ED].[EvaluationId] = @evaluationId";

            using (var conn = new SqlConnection(Config.GetConnectionString()))
            {
                using (var cmd = new SqlCommand(query, conn))
                {
                    cmd.Parameters.Add("@evaluationId", SqlDbType.Int);
                    cmd.Parameters["@evaluationId"].Value = evaluationId;

                    conn.Open();

                    var dt = new DataTable();
                    var da = new SqlDataAdapter(cmd);
                    da.Fill(dt);

                    foreach (DataRow dr in dt.Rows)
                    {
                        var skillId = dr.Db2Int("SkillId");

                        var skill = skillRepository.GetSkillById(skillId);

                        res.Add(getEvaluationDetailFromDataRow(dr, skill));
                    }
                }
            }

            res.Sort();

            return(res);
        }