public async Task <IActionResult> Register(RegisterViewModel model) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; IdentityResult result = await _userManager.CreateAsync(user, model.Password); ApplicationUser newUser = await _userManager.FindByNameAsync(model.UserName); if (result.Succeeded) { Profile userProfile = new Profile { User = user, Name = model.UserName }; _db.Profiles.Add(userProfile); _db.SaveChanges(); return(RedirectToAction("Index")); } else { return(View()); } }
public IActionResult Create(Boss boss) { _db.Bosses.Add(boss); _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Create(Gear newGear) { _db.Gears.Add(newGear); _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(NewSetViewModel newSetInfo) { //Create the new FullSet object FullSet newFullSet = new FullSet { SetName = newSetInfo.SetName }; _db.FullSets.Add(newFullSet); //Grab the User, Profile, and Boss to add to join tables var user = await _userManager.GetUserAsync(User); Profile userProfile = _db.Profiles.FirstOrDefault(m => m.User == user); Boss boss = _db.Bosses.FirstOrDefault(m => m.Id == newSetInfo.BossId); //Add BossId to FullSet newFullSet.BossId = boss.Id; //**********Add To Join Tables********** //Profile Join Table ProfileFullSet newProfileSet = new ProfileFullSet { Profile = userProfile, FullSet = newFullSet }; _db.ProfileFullSets.Add(newProfileSet); //Boss Join Table FullSetBoss newBossSet = new FullSetBoss { Boss = boss, BossId = boss.Id, FullSet = newFullSet }; _db.FullSetBosses.Add(newBossSet); //Gear Join Table //HeadSlot FullSetGear headSlot = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.HeadSlotId) }; _db.FullSetGears.Add(headSlot); //ChestSlot FullSetGear chestSlot = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.ChestSlotId) }; _db.FullSetGears.Add(chestSlot); //LegSlot FullSetGear legSlot = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.LegSlotId) }; _db.FullSetGears.Add(legSlot); //Boots FullSetGear boots = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.BootsId) }; _db.FullSetGears.Add(boots); //Gloves FullSetGear gloves = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.GlovesId) }; _db.FullSetGears.Add(gloves); //Cape FullSetGear cape = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.CapeId) }; _db.FullSetGears.Add(cape); //Necklace FullSetGear necklace = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.NecklaceId) }; _db.FullSetGears.Add(necklace); //Ring FullSetGear ring = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.RingId) }; _db.FullSetGears.Add(ring); //ArrowSlot FullSetGear arrowSlot = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.ArrowSlotId) }; _db.FullSetGears.Add(arrowSlot); //MainHand FullSetGear mainHand = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.MainHandId) }; _db.FullSetGears.Add(mainHand); //OffHand FullSetGear offHand = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.OffHandId) }; _db.FullSetGears.Add(offHand); //Spec Weapon FullSetGear specWeapon = new Models.FullSetGear { FullSet = newFullSet, Gear = _db.Gears.FirstOrDefault(m => m.Id == newSetInfo.SpecWeaponId) }; _db.FullSetGears.Add(offHand); //Save All Changes _db.SaveChanges(); return(RedirectToAction("Index")); }