예제 #1
0
        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);
        }
예제 #2
0
        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);
        }