Ejemplo n.º 1
0
        public static bool validateMemberQAResponse(QuestionAnswerReponseModel memberQAResponses)
        {
            var  validationResults = new List <ValidationResult>();
            var  validationContext = new ValidationContext(memberQAResponses, serviceProvider: null, items: null);
            bool isValid           = System.ComponentModel.DataAnnotations.Validator.TryValidateObject(memberQAResponses, validationContext, validationResults, true);

            return(isValid);
        }
Ejemplo n.º 2
0
        public bool UpsertQuestionAnswer(QuestionAnswerReponseModel choicesResponse)
        {
            const string logMethodName = "- QuestionAnswerResponse(QuestionAnswerReponseModel choicesResponse) - ";

            Log.Debug(logMethodName + "Begin Method");

            bool result = false;

            try
            {
                ASAMemberModel currentUser = GetMemberFromContext();
                if (_asaMemberAdapter.IsCurrentUser(choicesResponse.memberId))
                {
                    if (MemberProfileResponseValidation.validateMemberQAResponse(choicesResponse))
                    {
                        result = _asaMemberAdapter.UpsertQuestionAnswer(choicesResponse.memberId, choicesResponse.choicesList);
                    }
                    else
                    {
                        throw new System.ComponentModel.DataAnnotations.ValidationException();
                    }
                }
                else
                {
                    throw new WebFaultException <string>("Not Authorized", System.Net.HttpStatusCode.Unauthorized);
                }
            }
            catch (ValidationException validatEx)
            {
                string errMsg = validatEx.Message;
                if (choicesResponse.choicesList.Count == 0)
                {
                    errMsg = string.Format("{0}: choicesResponse failed validation {1}", "Exception executing your request in UpsertQuestionAnswer", "object choicesResponse.choicesList must have length greater than zero " + errMsg + ". Call exited without change.");
                }
                Log.Error(errMsg, validatEx.StackTrace);
            }
            catch (Exception ex)
            {
                Log.Error("Exception executing your request in UpsertQuestionAnswer:", ex);
            }
            Log.Debug(logMethodName + "End Method");
            return(result);
        }