public CharacterViewModel(AppSetting appSetting)
    {
        DataObj dbo = new DataObj(appSetting);

        raceList      = new SelectList(dbo.getAllRaces(), "id", "name");
        classList     = new SelectList(dbo.getAllClasses(), "id", "name");
        alignmentList = new SelectList(dbo.getAllAlignments(), "id", "name");
        weaponList    = new SelectList(dbo.getAllWeapons(), "id", "name");
        spellList     = new SelectList(dbo.getAllSpells(), "id", "name");
    }
    public CharacterViewModel(int characterId, AppSetting appSetting)
    {
        DataObj dbo = new DataObj(appSetting);

        Character character = dbo.pullCharInfoById(characterId);

        id = character.id;

        name = character.name;

        level = character.level.ToString();

        gender = character.gender;

        alignment = character.alignment;

        race = character.race;

        charClass = character.charClass;

        str  = character.str.ToString();
        con  = character.con.ToString();
        dex  = character.dex.ToString();
        inte = character.inte.ToString();
        cha  = character.cha.ToString();
        wis  = character.wis.ToString();

        armor     = character.armor;
        hitpoints = character.hitpoints;
        speed     = character.speed;

        spells  = character.spells;
        weapons = character.weapons;

        raceList      = new SelectList(dbo.getAllRaces(), "id", "name", race);
        classList     = new SelectList(dbo.getAllClasses(), "id", "name");
        alignmentList = new SelectList(dbo.getAllAlignments(), "id", "name");
        weaponList    = new SelectList(dbo.getAllWeapons(), "id", "name");
        spellList     = new SelectList(dbo.getAllSpells(), "id", "name");
    }
        public ActionResult CharacterEdit(CharacterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                DataObj dbo = new DataObj(appSetting);

                // RACE LIST
                IEnumerable <SelectListItem> raceList = new SelectList(dbo.getAllRaces(), "id", "name");

                // CLASS LIST
                IEnumerable <SelectListItem> classList = new SelectList(dbo.getAllClasses(), "id", "name");

                // ALIGNMENT LIST
                IEnumerable <SelectListItem> alignmentList = new SelectList(dbo.getAllAlignments(), "id", "name");

                // WEAPON LIST
                IEnumerable <SelectListItem> weaponList = new SelectList(dbo.getAllWeapons(), "id", "name");

                // SPELL LIST
                IEnumerable <SelectListItem> spellList = new SelectList(dbo.getAllSpells(), "id", "name");

                model.raceList      = raceList;
                model.classList     = classList;
                model.alignmentList = alignmentList;
                model.weaponList    = weaponList;
                model.spellList     = spellList;

                return(View("CharacterEdit", model));
            }
            else
            {
                DataObj dbo    = new DataObj(appSetting);
                int     userId = Int32.Parse(HttpContext.Session.GetString("UserID"));
                long    charId = dbo.editCharacter(model, userId);
                if (charId != -1)
                {
                    return(RedirectToAction("Index", new { id = charId }));
                }
                else
                {
                    // RACE LIST
                    IEnumerable <SelectListItem> raceList = new SelectList(dbo.getAllRaces(), "id", "name");

                    // CLASS LIST
                    IEnumerable <SelectListItem> classList = new SelectList(dbo.getAllClasses(), "id", "name");

                    // ALIGNMENT LIST
                    IEnumerable <SelectListItem> alignmentList = new SelectList(dbo.getAllAlignments(), "id", "name");

                    // WEAPON LIST
                    IEnumerable <SelectListItem> weaponList = new SelectList(dbo.getAllWeapons(), "id", "name");

                    // SPELL LIST
                    IEnumerable <SelectListItem> spellList = new SelectList(dbo.getAllSpells(), "id", "name");

                    model.raceList      = raceList;
                    model.classList     = classList;
                    model.alignmentList = alignmentList;
                    model.weaponList    = weaponList;
                    model.spellList     = spellList;

                    return(View("CharacterEdit", model));
                }
            }
        }