public JObject Generate()
        {
            try
            {
                var userData = SessionProvider.GetValue <UserModel>(CommonConst.CommonValue.SESSION_USER_KEY);
                if (userData == null)
                {
                    Logger.Debug("User session data is null");
                    return(ResponseBuilder.CreateReponse(CommonConst._401_UNAUTHORIZED));
                }

                DBQuery query = new DBQuery()
                {
                    Filters = new FilterQuery()
                    {
                        new Filter(CommonConst.CommonField.USER_ID, userData.user_id)
                    }
                };
                if (DBProxy.GetCount(ModuleAppConsts.Collection.AUTH_TOKEN_COLLECTION, query.Filters) >= MAX_KEYS)
                {
                    return(ResponseBuilder.CreateReponse(ApiKeyResponseCode._MAX_AUTH_TOKEN_REACHED));
                }

                var apikey = GenerateApiKey();
                var data   = GenerateApiKeyData(userData, apikey);

                if (DBProxy.WriteData(ModuleAppConsts.Collection.AUTH_TOKEN_COLLECTION, data, false))
                {
                    data[ModuleAppConsts.Field.AUTH_TOKEN] = apikey;
                    return(ResponseBuilder.CreateReponse(CommonConst._1_SUCCESS, data));
                }
                else
                {
                    Logger.Error("Error in writing data");
                    return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                return(ResponseBuilder.CreateReponse(CommonConst._500_SERVER_ERROR));
            }
        }