public IActionResult AddTab(string tabID) { var favorites = _appContext.Favorites.Find(_userManager.GetUserId(User)); var jsonString = JsonConvert.DeserializeObject <List <string> >(favorites.JSONTabs); jsonString.Add(tabID); favorites.JSONTabs = JsonConvert.SerializeObject(jsonString); _appContext.Favorites.Update(favorites); _appContext.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> Register(RegisterViewModel registerViewModel) { if (ModelState.IsValid) { var newUser = new IdentityUser() { UserName = registerViewModel.UserName }; var result = await _userManager.CreateAsync(newUser, registerViewModel.Password); var newFavorites = new Favorites(newUser.Id); _appContext.Favorites.Add(newFavorites); _appContext.SaveChanges(); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } } return(View(registerViewModel)); }