public async Task InsertNewUser(UserDto user)
        {
            IDatabase db = _redis.GetDatabase();

            string userKey = "user:" + user.Id.ToString();
            string userValue = await JsonConvert.SerializeObjectAsync(user);

            await db.StringSetAsync(userKey, userValue);
        }
        public async Task<IHttpActionResult> Register(UserDto model)
        {
            string message = "";

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var user = new ApplicationUser()
            {
                UserName = model.Username,
                Email = model.Email,
                FirstName = model.Firstname,
                LastName = model.Lastname,
                JoinDate = DateTime.UtcNow
            };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }
            else
            {
                var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                var encodedToken = HttpUtility.UrlEncode(code);

                string callback = "http://localhost:9095/confirm?userId={0}&code={1}";

                var url = string.Format(callback, user.Id, encodedToken);
                message = "Please click this link or paste into a browser: <a href='" + url + "'>" + url + "</a>";

                if (!string.IsNullOrEmpty(user.Id))
                {
                    UserManager.AddToRole(user.Id, "User");
                    UserDetail ud = (UserDetail)model;
                    ud.Id = user.Id;

                    await _userRepository.InsertUser(ud);
                    MostRecentUserDto rt = (MostRecentUserDto)model;
                    await _redis.InsertMostRecentUser(rt);
                }
            }

            await UserManager.EmailService.SendAsync(new IdentityMessage() { Subject = "You've been Registered.", Destination = user.Email, Body = message });

            var ret = new
            {
                success = true
            };

            return Ok(ret);
        }