public ActionResult LinksList() { var userId = CookieStore.GetCookie("userId"); var parsedUserId = 0; Int32.TryParse(userId, out parsedUserId); var userDTO = new UserDTO { Id = parsedUserId }; return View(userDTO); }
public async Task<ActionResult> Index() { var userDTO = new UserDTO(); var userId = CookieStore.GetCookie("userId"); var parsedUserId = 0; Int32.TryParse(userId, out parsedUserId); var existingUser = await _usersRepository.Get(parsedUserId); if (String.IsNullOrEmpty(userId) || existingUser == null) { var user = new User(); await _usersRepository.Insert(user); existingUser = user; CookieStore.SetCookie("userId", user.Id.ToString(), TimeSpan.FromDays(365)); } userDTO.Id = existingUser.Id; return View(userDTO); }