Beispiel #1
0
        // ?POST:
        public ActionResult _createAttributesDataResult(string classID, string heroName, string description,
                                                        string background, string appearance, string character,
                                                        AttributeLvl StrAttribute, AttributeLvl DexAttribute, AttributeLvl ConAttribute, AttributeLvl IntAttribute,
                                                        AttributeLvl WisAttribute, AttributeLvl ChaAttribute)
        {
            ViewBag.classID     = classID;
            ViewBag.heroName    = heroName;
            ViewBag.description = description;

            ViewBag.background = background;
            ViewBag.appearance = appearance;
            ViewBag.character  = character;

            ViewBag.StrAttribute = StrAttribute;
            ViewBag.DexAttribute = DexAttribute;
            ViewBag.ConAttribute = ConAttribute;
            ViewBag.IntAttribute = IntAttribute;
            ViewBag.WisAttribute = WisAttribute;
            ViewBag.ChaAttribute = ChaAttribute;

            int heroID = SaveNewHero(classID, heroName, description, background, appearance, character,
                                     StrAttribute, DexAttribute, ConAttribute, IntAttribute, WisAttribute, ChaAttribute);

            return(RedirectToAction("Details", "Heroes", new { id = heroID }));
        }
Beispiel #2
0
        public int SaveNewHero(string _classID, string _heroName, string _description,
                               string _background, string _appearance, string _character,
                               AttributeLvl _StrAttribute, AttributeLvl _DexAttribute, AttributeLvl _ConAttribute,
                               AttributeLvl _IntAttribute, AttributeLvl _WisAttribute, AttributeLvl _ChaAttribute)
        {
            int idClass = Int32.Parse(_classID);
            var x       = db.classes.Where(p => p.IDClass == idClass).FirstOrDefault();


            Hero hero = new Hero
            {
                name         = _heroName,
                conceptLvl   = CountWords(_description),
                description  = _description,
                background   = _background,
                appearance   = _appearance,
                character    = _character,
                StrAttribute = _StrAttribute,
                DexAttribute = _DexAttribute,
                ConAttribute = _ConAttribute,
                IntAttribute = _IntAttribute,
                WisAttribute = _WisAttribute,
                ChaAttribute = _ChaAttribute,
                gold         = 500,
                exp          = 0,
                Content      = db.contents.First(u => u.ApplicationUser.UserName == User.Identity.Name),
                IDContent    = db.contents.First(u => u.ApplicationUser.UserName == User.Identity.Name).IDContent,
                Class        = db.classes.First(p => p.IDClass == idClass),
                IDClass      = idClass
            };

            db.heroes.Add(hero);
            db.SaveChanges();

            return(hero.IDHero);
        }