public bool ConfirmEmail(Guid tokenId)
        {
            bool result = false;
            Token token = UserTokensService.Get(tokenId);

            ApplicationUserManager userManager = UserService.GetUserManager();
            ApplicationUser user = userManager.FindByName(token.UserName);
            if (user != null)
            {
                // Set the EmailConfirmed flag in AspNetUsers table
                DataProvider.ExecuteNonQuery(GetConnection, "dbo.AspNetUsers_UpdateEmailConfirmed"
                   , inputParamMapper: delegate (SqlParameterCollection UpdateEmailConfirmed)
                   {
                       UpdateEmailConfirmed.AddWithValue("@EmailConfirmed", true);
                       UpdateEmailConfirmed.AddWithValue("@UserName", token.UserName);
                   });

                // Insert new record in Users table
                ApplicationUser au = UserService.GetUserbyUserName(token.UserName);
                UserInfoAddRequest req = new UserInfoAddRequest();
                req.UserName = token.UserName;
                req.Phone = au.PhoneNumber;
                req.Email = au.Email;

                Insert(req, au.Id);

                // Delete the token from UserTokens table
                UserTokensService.Delete(tokenId);
                result = true;
            }
            return result;
        }
 public HttpResponseMessage DeletsUserInfo(UserInfoAddRequest model)
 {
     if (!ModelState.IsValid)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
     }
     return Request.CreateResponse(model);
 }
        public HttpResponseMessage AddUserData(UserInfoAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            ItemResponse<int> response = new ItemResponse<int>();
            string userId = UserService.GetCurrentUserId();
            response.Item = _userDataService.Insert(model, userId);

            return Request.CreateResponse(response);
        }
        public int Insert(UserInfoAddRequest model, string userId)
        {
            var id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_Insert",
                inputParamMapper: delegate (SqlParameterCollection parameterCollection)
                {
                    parameterCollection.AddWithValue("@FirstName", model.FirstName);
                    parameterCollection.AddWithValue("@LastName", model.LastName);
                    parameterCollection.AddWithValue("@UserName", model.UserName);
                    parameterCollection.AddWithValue("@Email", model.Email);
                    parameterCollection.AddWithValue("@Phone", model.Phone);
                    parameterCollection.AddWithValue("@Gender", model.Gender);
                    parameterCollection.AddWithValue("@Bio", model.Bio);
                    parameterCollection.AddWithValue("@UserId", userId);

                    SqlParameter s = new SqlParameter("@Id", System.Data.SqlDbType.Int)
                    {
                        Direction = System.Data.ParameterDirection.Output
                    };
                    parameterCollection.Add(s);
                },

                returnParameters: delegate (SqlParameterCollection para)
                {
                    int.TryParse(para["@Id"].Value.ToString(), out id);
                }

                );
            return id;
        }