Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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));
        }