private string AddNewResponse(object data) { BaseResponseModel response = jsonHelper.FromJson <BaseResponseModel>(data.ToString()); if (!string.IsNullOrEmpty(jsonHelper.ErrorMessage)) { return(jsonHelper.ErrorMessage); } string result = "Error - unable to add new response record"; List <UserDataModel> existingUsers = userService.GetUsers(); List <SurveyDataModel> existingSurveys = surveyService.GetSurveys(); if (existingUsers != null && existingSurveys != null) { if (existingUsers.Exists(o => o.UserID == response.UserID)) { if (existingSurveys.Exists(o => o.SurveyID == response.SurveyID)) { if (responseService.AddNewResponse(response)) { result = "Successfully added new response record"; } } else { result = "Survey not found - unable to add response record"; } } else { result = "User not found - unable to add response record"; } } return(result); }