public BuffAndEffectVM GetById(int?id)
        {
            BuffAndEffectVM buffAndEffect = _context.BuffAndEffects
                                            .Include(d => d.RuleSet)
                                            .Include(d => d.BuffAndEffectCommand)
                                            .Where(x => x.BuffAndEffectId == id && x.IsDeleted != true)
                                            .Select(x => new BuffAndEffectVM()
            {
                BuffAndEffectCommand = x.BuffAndEffectCommand,
                BuffAndEffectId      = x.BuffAndEffectId,
                Command     = x.Command,
                CommandName = x.CommandName,
                Description = x.Description,
                gmOnly      = x.gmOnly,
                ImageUrl    = x.ImageUrl,
                IsAssignedToAnyCharacter = _context.CharacterBuffAndEffects.Where(q => q.BuffAndEffectID == x.BuffAndEffectId && q.IsDeleted != true).Any(),
                IsDeleted             = x.IsDeleted,
                Metatags              = x.Metatags,
                Name                  = x.Name,
                ParentBuffAndEffectId = x.ParentBuffAndEffectId,
                RuleSet               = x.RuleSet,
                RuleSetId             = x.RuleSetId,
                Stats                 = x.Stats,
            })
                                            .FirstOrDefault();

            if (buffAndEffect == null)
            {
                return(buffAndEffect);
            }

            buffAndEffect.BuffAndEffectCommand = buffAndEffect.BuffAndEffectCommand.Where(p => p.IsDeleted != true).ToList();

            return(buffAndEffect);
        }
        public List <BuffAndEffectVM> SP_GetBuffAndEffectByRuleSetId_Old(int rulesetId, int page, int pageSize)
        {
            List <BuffAndEffectVM> _buffAndEffectList = new List <BuffAndEffectVM>();
            RuleSet ruleset = new RuleSet();

            short  num = 0;
            string connectionString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value;

            SqlConnection  connection = new SqlConnection(connectionString);
            SqlCommand     command    = new SqlCommand();
            SqlDataAdapter adapter    = new SqlDataAdapter();
            DataSet        ds         = new DataSet();

            try
            {
                connection.Open();
                command = new SqlCommand("BuffAndEffect_GetByRulesetID", connection);

                // Add the parameters for the SelectCommand.
                command.Parameters.AddWithValue("@RulesetID", rulesetId);
                command.Parameters.AddWithValue("@page", page);
                command.Parameters.AddWithValue("@size", pageSize);
                command.CommandType = CommandType.StoredProcedure;

                adapter.SelectCommand = command;

                adapter.Fill(ds);
                command.Dispose();
                connection.Close();
            }
            catch (Exception ex)
            {
                command.Dispose();
                connection.Close();
            }



            if (ds.Tables[1].Rows.Count > 0)
            {
                ruleset = _repo.GetRuleset(ds.Tables[1], num);
            }

            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    BuffAndEffectVM _buffAndEffect = new BuffAndEffectVM();
                    _buffAndEffect.Name        = row["Name"] == DBNull.Value ? null : row["Name"].ToString();
                    _buffAndEffect.Stats       = row["Stats"] == DBNull.Value ? null : row["Stats"].ToString();
                    _buffAndEffect.Metatags    = row["Metatags"] == DBNull.Value ? null : row["Metatags"].ToString();
                    _buffAndEffect.Command     = row["Command"] == DBNull.Value ? null : row["Command"].ToString();
                    _buffAndEffect.CommandName = row["CommandName"] == DBNull.Value ? null : row["CommandName"].ToString();
                    _buffAndEffect.Description = row["Description"] == DBNull.Value ? null : row["Description"].ToString();
                    _buffAndEffect.gmOnly      = row["gmOnly"] == DBNull.Value ? null : row["gmOnly"].ToString();
                    _buffAndEffect.ImageUrl    = row["ImageUrl"] == DBNull.Value ? null : row["ImageUrl"].ToString();
                    //_buffAndEffect.Level = row["Level"] == DBNull.Value ? null : row["Level"].ToString();
                    _buffAndEffect.IsDeleted = row["IsDeleted"] == DBNull.Value ? false : Convert.ToBoolean(row["IsDeleted"]);
                    //_buffAndEffect.IsEnabled = row["IsEnabled"] == DBNull.Value ? false : Convert.ToBoolean(row["IsEnabled"]);

                    _buffAndEffect.BuffAndEffectId          = row["BuffAndEffectId"] == DBNull.Value ? 0 : Convert.ToInt32(row["BuffAndEffectId"].ToString());
                    _buffAndEffect.ParentBuffAndEffectId    = row["ParentBuffAndEffectId"] == DBNull.Value ? 0 : Convert.ToInt32(row["ParentBuffAndEffectId"].ToString());
                    _buffAndEffect.RuleSetId                = row["RuleSetId"] == DBNull.Value ? 0 : Convert.ToInt32(row["RuleSetId"].ToString());
                    _buffAndEffect.IsAssignedToAnyCharacter = row["IsAssignedToAnyCharacter"] == DBNull.Value ? false : true;

                    _buffAndEffect.RuleSet = ruleset;
                    _buffAndEffectList.Add(_buffAndEffect);
                }
            }
            return(_buffAndEffectList);
        }