public SurveyListModel GetResponseAndTotals(string surveyId) { SurveyListModel sList = null; try { _log.Info("ASA.Web.Services.SurveyService.GetResponseAndTotals() starting ..."); if (_surveyAdapter == null) { _log.Error("ASA.Web.Services.SurveyService.GetResponseAndTotals(): " + _surveyAdapterExceptionMessage); throw new SurveyBadDataException("Null adapter in ASA.Web.Services.SurveyService.GetResponseAndTotals()"); } else if (string.IsNullOrEmpty(surveyId)) { _log.Info("Survey Id was not provided to access GetResponseAndTotals"); sList = new SurveyListModel(); var error = new ErrorModel("Survey Id was not provided to access GetResponseAndTotals", "Web Survey Service"); sList.ErrorList.Add(error); } else { sList = _surveyAdapter.GetResponseAndTotals(Convert.ToInt32(surveyId)); } } catch (Exception ex) { _log.Error("ASA.Web.Services.SurveyService.GetResponseAndTotalss(): Exception => " + ex.ToString()); throw new SurveyOperationException("Web Survey Service - Exception in ASA.Web.Services.SurveyService.GetResponseAndTotals()", ex); } _log.Info("ASA.Web.Services.SurveyService.GetResponseAndTotals() ending ..."); return(sList); }
public SurveyListModel GetIndividualsResponse(string surveyId, string individualId, string surveyQuestionId) { var memberAdapter = new AsaMemberAdapter(); SurveyListModel sList = null; try { _log.Info("ASA.Web.Services.SurveyService.GetIndividualsResponse() starting ..."); int memberId = memberAdapter.GetMemberIdFromContext(); if (_surveyAdapter == null) { _log.Error("ASA.Web.Services.SurveyService.GetIndividualsResponse(): " + _surveyAdapterExceptionMessage); throw new SurveyBadDataException("Null adapter in ASA.Web.Services.SurveyService.GetIndividualsResponse()"); } if (string.IsNullOrEmpty(surveyId)) { _log.Info("Survey Id was not provided to access GetIndividualsResponse"); sList = new SurveyListModel(); var error = new ErrorModel("Survey Id was not provided to access GetIndividualsResponse", "Web Survey Service"); sList.ErrorList.Add(error); } else if (string.IsNullOrEmpty(individualId)) { _log.Info("Individual Id was not provided to access GetIndividualsResponse"); sList = new SurveyListModel(); var error = new ErrorModel("Individual Id was not provided to access GetIndividualsResponse", "Web Survey Service"); sList.ErrorList.Add(error); } else { //no errors then continue sList = _surveyAdapter.GetIndividualsResponse(Convert.ToInt32(surveyId), memberId); } } catch (Exception ex) { _log.Error("ASA.Web.Services.SurveyService.GetSurveyQuestions(): Exception => " + ex.ToString()); throw new SurveyOperationException("Web Survey Service - Exception in ASA.Web.Services.SurveyService.GetSurveyQuestion()", ex); } _log.Info("ASA.Web.Services.SurveyService.GetSurveyQuestion() ending ..."); if (sList.Surveys.Any()) { sList.Surveys[0].SurveyId = surveyId; sList.Surveys[0].SurveyQuestionId = surveyQuestionId; } return(sList); }
public static bool ValidateInputSurveyList(SurveyListModel sList) { bool bValid = false; if (sList != null && sList.Surveys != null) { bValid = true; foreach (SurveyModel survey in sList.Surveys) { bValid &= survey.IsValid(); if (!bValid) { break; } } } return(bValid); }
/// <summary> /// Gets the question and response. /// </summary> /// <param name="surveyId">The survey id.</param> /// <returns></returns> /// <exception cref="SurveyOperationException">Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetQuestionAndResponse()</exception> public SurveyListModel GetQuestionAndResponse(int surveyId) { const string logMethodName = ".GetQuestionAndResponse(string surveyId) - "; Log.Debug(logMethodName + "Begin Method"); var sList = new SurveyListModel(); var memberAdapter = new AsaMemberAdapter(); try { var survey = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").GetSurveyById(surveyId).ToDomainModel(); if (survey != null) { var response = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").GetUserSurveyResults(surveyId, memberAdapter.GetMemberIdFromContext()).ToDomainModel(); sList.Surveys = new List <SurveyModel>(); if (response.Surveys.Any()) { survey.Response = response.Surveys.First().Response; survey.ResponseCount = 1; } sList.Surveys = new List <SurveyModel>() { survey }; } } catch (Exception ex) { Log.Error("ASA.Web.Services.SurveyService.SurveyAdapter.GetQuestionAndResponse(): Exception =>" + ex.ToString()); throw new SurveyOperationException("Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetQuestionAndResponse()", ex); } Log.Debug(logMethodName + "End Method"); return(sList); }
/// <summary> /// Gets the response and totals. /// </summary>memberAdapter /// <param name="surveyId">The survey id.</param> /// <returns></returns> /// <exception cref="SurveyOperationException">Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetResponseAndTotals()</exception> public SurveyListModel GetResponseAndTotals(int surveyId) { const string logMethodName = ".GetResponseAndTotals(string surveyId) - "; Log.Debug(logMethodName + "Begin Method"); var sList = new SurveyListModel(); try { var memberAdapter = new AsaMemberAdapter(); var survey = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").GetSurveyById(surveyId); if (survey != null) { foreach (var option in survey.SurveyOptions) { sList.Surveys.Add(new SurveyModel() { IndividualId = memberAdapter.GetActiveDirectoryKeyFromContext(), MemberId = memberAdapter.GetMemberIdFromContext(), SurveyId = survey.SurveyId.ToString(CultureInfo.InvariantCulture), SurveyQuestionId = survey.SurveyId.ToString(CultureInfo.InvariantCulture), Response = option.OptionValue, ResponseCount = option.TotalResponseCount, QuestionText = survey.SurveyQuestion, }); } } } catch (Exception ex) { Log.Error("ASA.Web.Services.SurveyService.SurveyAdapter.GetSurveyQuestion(): Exception =>" + ex.ToString()); throw new SurveyOperationException("Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetResponseAndTotals()", ex); } Log.Debug(logMethodName + "End Method"); return(sList); }
/// <summary> /// To the domain model. /// </summary> /// <param name="surveyResponseDataContract">The survey response data contract.</param> /// <returns></returns> public static SurveyListModel ToDomainModel(this SurveyResponseContract surveyResponseDataContract) { if (null == surveyResponseDataContract) { return(new SurveyListModel()); } var toReturn = new SurveyListModel { Surveys = new List <SurveyModel> { new SurveyModel() { IndividualId = new AsaMemberAdapter().GetActiveDirectoryKeyFromContext(), MemberId = surveyResponseDataContract.MemberId, ResponseCount = surveyResponseDataContract.TotalResponseCount, Response = surveyResponseDataContract.SurveyResponseId.ToString(CultureInfo.InvariantCulture), } } }; return(toReturn); }