Beispiel #1
0
        public IActionResult Warlock()
        {
            AddWarlockViewModel soloView = new AddWarlockViewModel

                                           (

                context.Abilities.ToList(),

                context.Weapons.ToList(),
                context.Spells.ToList()

                                           );



            return(View("AddWarlock", soloView));
        }
Beispiel #2
0
        public IActionResult Warlock(AddWarlockViewModel model)
        {
            if (ModelState.IsValid)
            {
                Warlock newSolo = new Warlock();


                newSolo.Name           = model.Name;
                newSolo.ARM            = model.ARM;
                newSolo.CMD            = model.CMD;
                newSolo.DEF            = model.DEF;
                newSolo.MAT            = model.MAT;
                newSolo.PointCost      = model.PointCost;
                newSolo.RAT            = model.RAT;
                newSolo.SPD            = model.SPD;
                newSolo.STR            = model.STR;
                newSolo.WarbeastPoints = model.WarbeastPoints;
                newSolo.factionName    = model.Faction;


                context.Warlocks.Add(newSolo);
                context.SaveChanges();

                if (model.abilIDS != null)
                {
                    foreach (var abil in model.abilIDS)
                    {
                        WarlockAbillity NewSoloAbility = new WarlockAbillity();
                        NewSoloAbility.AbillityId = abil;
                        NewSoloAbility.WarlockId  = newSolo.ID;
                        context.WarlockAbillities.Add(NewSoloAbility);
                        context.SaveChanges();
                    }
                }


                if (model.weapIDS != null)
                {
                    foreach (var weap in model.weapIDS)
                    {
                        WarlockWeapon NewSoloWeapon = new WarlockWeapon();
                        NewSoloWeapon.WeaponId  = weap;
                        NewSoloWeapon.WarlockId = newSolo.ID;
                        context.WarlockWeapons.Add(NewSoloWeapon);
                        context.SaveChanges();
                    }
                }

                if (model.spellIDS != null)
                {
                    foreach (var spell in model.spellIDS)
                    {
                        WarlockSpell NewSoloSpell = new WarlockSpell();
                        NewSoloSpell.SpellId   = spell;
                        NewSoloSpell.WarlockId = newSolo.ID;
                        context.WarlockSpells.Add(NewSoloSpell);
                        context.SaveChanges();
                    }
                }



                return(Redirect("/"));
            }

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