Exemplo n.º 1
0
        public AlertListModel GetAlerts()
        {
            const string logMethodName = ".GetUserAlerts() - ";

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

            AlertListModel aList = null;

            try
            {
                var adapter = new AsaMemberAdapter();
                if (adapter.GetMemberIdFromContext() > 0)
                {
                    if (_alertAdapter == null)
                    {
                        _log.Error(logMethodName + "ASA.Web.Services.AlertService.GetUserAlerts(): " + AlertAdapterExceptionMessage);
                        throw new AlertBadDataException("Null adapter in ASA.Web.Services.AlertService.GetUserAlerts()");
                    }

                    else
                    {
                        aList = _alertAdapter.GetAlerts(adapter.GetMemberIdFromContext());
                    }
                }
                else
                {
                    _log.Warn(logMethodName + "A user who is anonymous is trying to access GetUserAlerts");
                    aList = new AlertListModel();
                    var error = new ErrorModel("A user who is anonymous is trying to access GetUserAlerts", "Web Alert Service");
                    aList.ErrorList.Add(error);
                }
            }
            catch (Exception ex)
            {
                //Alerts is non-critical functionality so if there is some kind of problem getting alerts we simply log it and move on my returning a null set.
                _log.Error(logMethodName + "ASA.Web.Services.AlertService.GetUserAlerts(): Exception => " + ex.ToString());
                //throw new AlertOperationException("Web Alert Service - Exception in ASA.Web.Services.AlertService.GetUserAlerts()", ex);
            }

            _log.Debug(logMethodName + "End Method");

            return(aList ?? (aList = new AlertListModel()));
        }
Exemplo n.º 2
0
        public void AssociateLessonWithRegisteredUser(string userLessonId)
        {
            int  validatedUserLessonId;
            bool userLessonIdIsValid = Int32.TryParse(userLessonId, out validatedUserLessonId);

            if (userLessonIdIsValid)
            {
                var memberAdapter = new AsaMemberAdapter();
                var userId        = memberAdapter.GetMemberIdFromContext();

                SaltServiceAgent.AssociateLessonsWithUser(Convert.ToInt32(validatedUserLessonId), userId);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public ResultCodeModel InsertSurvey(SurveyModel survey)
        {
            ResultCodeModel result;

            try
            {
                var memberAdapter = new AsaMemberAdapter();
                //add system data
                //response status will be hardcoded in deployment scripts so it will be the same for all environments
                survey.ResponseDate   = DateTime.Now;
                survey.ResponseStatus = "21B65800-5F9A-421F-9E82-DA13B111F790";
                survey.MemberId       = memberAdapter.GetMemberIdFromContext();

                if (SurveyValidation.ValidateSurvey(survey))
                {
                    _log.Info("ASA.Web.Services.SurveyService.InsertSurvey() starting ...");
                    result = _surveyAdapter.InsertSurvey(survey);
                    _log.Info("ASA.Web.Services.SurveyService.InsertSurvey() ending ...");
                }
                else
                {
                    result = new ResultCodeModel();
                    var error = new ErrorModel("Invalid information input for this survey", "Web Survey Service");
                    _log.Error("ASA.Web.Services.SurveyService.InsertSurvey(): Invalid information input for this survey");
                    result.ErrorList.Add(error);

                    if (Config.Testing)
                    {
                        //get validation errors out of list and retrun them
                        if (survey.ErrorList.Count > 0)
                        {
                            foreach (ErrorModel em in survey.ErrorList)
                            {
                                //if not empty copy message
                                if (!string.IsNullOrEmpty(em.Code))
                                {
                                    result.ErrorList.Add(em);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error("ASA.Web.Services.SurveyService.InsertSurvey(): Exception => " + ex.ToString());
                throw new SurveyOperationException("Web Survey Service - Exception in ASA.Web.Services.SurveyService.InsertSurvey()", ex);
            }

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Converts to the domain object.
        /// </summary>
        /// <param name="paymentReminder">The payment reminder.</param>
        /// <returns></returns>
        public static ReminderModel ToDomainObject(this PaymentReminderContract paymentReminder)
        {
            var userAdapter = new AsaMemberAdapter();

            return(new ReminderModel()
            {
                DayOfMonth = paymentReminder.DayOfMonth,
                ID = paymentReminder.PaymentReminderId.ToString(CultureInfo.InvariantCulture),
                IsActive = true,
                MemberId = userAdapter.GetMemberIdFromContext(),
                IndividualId = userAdapter.GetActiveDirectoryKeyFromContext(),
                NumberOfLoans = paymentReminder.NumberOfLoans.HasValue?paymentReminder.NumberOfLoans.Value:0,
                ServicerName = paymentReminder.ServicerName
            });
        }
Exemplo n.º 6
0
        private int GetMemberId()
        {
            if (HttpContext.Current.Items.Contains("MembershipId"))
            {
                return(Convert.ToInt32(HttpContext.Current.Items["MembershipId"]));
            }
            else
            {
                var adapter = new AsaMemberAdapter();

                HttpContext.Current.Items.Add("MembershipId", adapter.GetMemberIdFromContext());
            }

            return(Convert.ToInt32(HttpContext.Current.Items["MembershipId"]));
        }
Exemplo n.º 7
0
        /// <summary>
        /// To the member lesson contract.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="lessonId">The lesson id.</param>
        /// <returns></returns>
        public static MemberLessonContract ToDataContract(this User user, int lessonId)
        {
            var toReturn      = new MemberLessonContract();
            var memberAdapter = new AsaMemberAdapter();

            toReturn.LessonUserId = user.UserId;
            toReturn.MemberId     = memberAdapter.GetMemberIdFromContext();
            toReturn.LessonId     = lessonId;
            toReturn.CurrentStep  = lessonId == LessonTypes.HowDoesYourCashFlow
                                       ? user.Lesson1Step
                                       : lessonId == LessonTypes.MasterYourPlastic
                                             ? user.Lesson2Step
                                             : lessonId == LessonTypes.OwnYourStudentLoans ? user.Lesson3Step : 0;

            return(toReturn);
        }
Exemplo n.º 8
0
        /// <summary>
        /// To the domain model.
        /// </summary>
        /// <param name="surveyDataContract">The survey data contract.</param>
        /// <returns></returns>
        public static SurveyModel ToDomainModel(this SurveyContract surveyDataContract)
        {
            var memberAdapter = new AsaMemberAdapter();

            return(surveyDataContract == null
                       ? null
                       : new SurveyModel()
            {
                ListOfAnswerOptions = surveyDataContract.ListOfValues,
                QuestionText = surveyDataContract.SurveyQuestion,
                SurveyId = surveyDataContract.SurveyId.ToString(CultureInfo.InvariantCulture),
                IndividualId = memberAdapter.GetActiveDirectoryKeyFromContext(),
                MemberId = memberAdapter.GetMemberIdFromContext(),
                SurveyQuestionId = surveyDataContract.SurveyId.ToString(CultureInfo.InvariantCulture)
            });
        }
Exemplo n.º 9
0
        public SelfReportedLoanListModel GetLoans(string ssn)
        {
            _log.Debug(string.Format("START ASA.Web.Services.LoanService.GetLoan(): ssn={0}", !string.IsNullOrEmpty(ssn)?ssn:"null"));
            HttpHeadersHelper.SetNoCacheResponseHeaders(WebOperationContext.Current);

            SelfReportedLoanListModel loans         = null;
            IAsaMemberAdapter         memberAdapter = null;

            memberAdapter = new AsaMemberAdapter();

            if (LoanValidation.ValidateInputSsn(ssn))
            {
                _log.Debug("calling GetActiveDirectoryKeyFromContext now.");
                int?           id     = memberAdapter.GetMemberIdFromContext();
                ASAMemberModel member = memberAdapter.GetMember(id.Value);

                if (_loanAdapter == null)
                {
                    _log.Error(_loanAdapterExceptionMessage);
                    loans = new SelfReportedLoanListModel();
                    ErrorModel error = new ErrorModel(_loanAdapterExceptionMessage, "Web Loan Service");
                    _log.Error("ASA.Web.Services.LoanService.GetLoan(): " + _loanAdapterExceptionMessage);
                    loans.ErrorList.Add(error);
                }
                else if (member != null)// we should never try to retrieve loans for someone who isn't found as the logged-in member from context.
                {
                    loans = _loanAdapter.GetLoans(ssn, member);
                }

                if (loans == null)
                {
                    _log.Debug("No loans were retrieved for this SSN: " + ssn);
                    loans = new SelfReportedLoanListModel();
                    loans.ErrorList.Add(new ErrorModel("No Loans were retrieved for this SSN."));
                }
            }
            else
            {
                loans = new SelfReportedLoanListModel();
                ErrorModel error = new ErrorModel("Invalid search criteria", "Web Loan Service");
                _log.Warn("ASA.Web.Services.LoanService.GetLoan(): Invalid search criteria");
                loans.ErrorList.Add(error);
            }

            _log.Debug(string.Format("END ASA.Web.Services.LoanService.GetLoan(): ssn={0}", !string.IsNullOrEmpty(ssn) ? ssn : "null"));
            return(loans);
        }
Exemplo n.º 10
0
        /// <summary>
        /// To the user.
        /// </summary>
        /// <param name="userLessonContracts">The user lesson contracts.</param>
        /// <returns></returns>
        public static User ToDomainObject(this MemberLessonContract[] userLessonContracts)
        {
            var toReturn           = new User();
            var memberAdapter      = new AsaMemberAdapter();
            var activeDirectoryKey = memberAdapter.GetActiveDirectoryKeyFromContext();
            var lesson1            = userLessonContracts.FirstOrDefault(l => l.LessonId == 1);
            var lesson2            = userLessonContracts.FirstOrDefault(l => l.LessonId == 2);
            var lesson3            = userLessonContracts.FirstOrDefault(l => l.LessonId == 3);

            toReturn.IndividualId = !string.IsNullOrWhiteSpace(activeDirectoryKey)
                                        ? new Guid(memberAdapter.GetActiveDirectoryKeyFromContext())
                                        : Guid.Empty;
            toReturn.Lesson1Step = lesson1 != null && lesson1.CurrentStep.HasValue ? lesson1.CurrentStep.Value : 0;
            toReturn.Lesson2Step = lesson2 != null && lesson2.CurrentStep.HasValue ? lesson2.CurrentStep.Value : 0;
            toReturn.Lesson3Step = lesson3 != null && lesson3.CurrentStep.HasValue ? lesson3.CurrentStep.Value : 0;
            toReturn.MemberId    = memberAdapter.GetMemberIdFromContext();
            toReturn.UserId      = userLessonContracts.Any() ? userLessonContracts.First().LessonUserId : 0;

            return(toReturn);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Saves the reminders.
        /// </summary>
        /// <param name="rList">The r list.</param>
        /// <returns></returns>
        /// <exception cref="ReminderOperationException">Web Reminder Service - ASA.Web.Services.ReminderService.ReminderAdapter.SaveReminders()</exception>
        public ResultCodeModel SaveReminders(ReminderListModel rList)
        {
            var toReturn = new ResultCodeModel(1);

            try
            {
                var memberAdapter = new AsaMemberAdapter();
                int memberId      = memberAdapter.GetMemberIdFromContext();
                foreach (var r in rList.Reminders)
                {
                    r.MemberId = memberId;
                }

                rList.Reminders = rList.Reminders.Where(r => r.IsActive).ToList();

                var result = SaltServiceAgent.SaveUserPaymentReminders(memberId, rList.ToDataContract());

                switch (result)
                {
                case RemindersUpdateStatus.Failure:
                    toReturn.ResultCode = 0;
                    break;

                case RemindersUpdateStatus.Success:
                    toReturn.ResultCode = 1;
                    break;

                case RemindersUpdateStatus.PartialSuccess:
                    toReturn.ResultCode = 2;
                    break;
                }
            }

            catch (Exception ex)
            {
                _log.Error("ASA.Web.Services.ReminderService.ReminderAdapter.SaveReminders(): Exception =>" + ex.ToString());
                throw new ReminderOperationException("Web Reminder Service - ASA.Web.Services.ReminderService.ReminderAdapter.SaveReminders()", ex);
            }

            return(toReturn);
        }
Exemplo n.º 12
0
        /// <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);
        }
Exemplo n.º 13
0
 public bool PublicVlcEndpoint(VLCQuestionResponseModel response)
 {
     try
     {
         if (VLCQuestionResponseValidation.validateQuestionResponseModel(response))
         {
             var _memberAdapter = new AsaMemberAdapter();
             var memberId       = _memberAdapter.GetMemberIdFromContext();
             response.MemberID     = memberId;
             response.ResponseDate = System.DateTime.Now;
             return(_surveyAdapter.AddVlcResponse(response));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         _log.Error("ASA.Web.Services.SurveyService.AddVlcResponse(): Exception => " + ex.ToString());
         throw new SurveyOperationException("Web Survey Service - Exception in ASA.Web.Services.SurveyService.AddVlcResponse()", ex);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// To the user.
        /// </summary>
        /// <param name="userLessonContract">The user lesson contract.</param>
        /// <returns></returns>
        public static User ToDomainObject(this MemberLessonContract userLessonContract)
        {
            var toReturn           = new User();
            var memberAdapter      = new AsaMemberAdapter();
            var activeDirectoryKey = memberAdapter.GetActiveDirectoryKeyFromContext();

            toReturn.IndividualId = !string.IsNullOrWhiteSpace(activeDirectoryKey)
                                        ? new Guid(activeDirectoryKey)
                                        : Guid.Empty;
            toReturn.MemberId = memberAdapter.GetMemberIdFromContext();

            if (null == userLessonContract)
            {
                return(toReturn);
            }

            toReturn.UserId      = userLessonContract.LessonUserId;
            toReturn.Lesson1Step = userLessonContract.LessonId == 1 && userLessonContract.CurrentStep.HasValue? userLessonContract.CurrentStep.Value : 0;
            toReturn.Lesson2Step = userLessonContract.LessonId == 2 && userLessonContract.CurrentStep.HasValue ? userLessonContract.CurrentStep.Value : 0;
            toReturn.Lesson3Step = userLessonContract.LessonId == 3 && userLessonContract.CurrentStep.HasValue ? userLessonContract.CurrentStep.Value : 0;

            return(toReturn);
        }
Exemplo n.º 15
0
        public ReminderListModel GetReminders()
        {
            ReminderListModel rList = null;
            var memberAdapter       = new AsaMemberAdapter();

            try
            {
                _log.Info("ASA.Web.Services.ReminderService.GetReminders() starting ...");
                int memberId = memberAdapter.GetMemberIdFromContext();

                if (_reminderAdapter == null)
                {
                    _log.Error("ASA.Web.Services.ReminderService.GetReminders(): " + _reminderAdapterExceptionMessage);
                    throw new ReminderBadDataException("Null adapter in ASA.Web.Services.ReminderService.GetReminders()");
                }
                else if (memberId <= 0)
                {
                    _log.Info("A user who is anonymous is trying to access GetReminders");
                    rList = new ReminderListModel();
                    ErrorModel error = new ErrorModel("A user who is anonymous is trying to access GetReminders", "Web Reminder Service");
                    rList.ErrorList.Add(error);
                }
                else
                {
                    rList = _reminderAdapter.GetReminders(memberId);
                }
            }
            catch (Exception ex)
            {
                _log.Error("ASA.Web.Services.ReminderService.GetReminders(): Exception => " + ex.ToString());
                throw new ReminderOperationException("Web Reminder Service - Exception in ASA.Web.Services.ReminderService.GetReminders()", ex);
            }

            _log.Info("ASA.Web.Services.ReminderService.GetReminders() ending ...");
            return(rList);
        }
Exemplo n.º 16
0
        /// <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);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the individuals response.
        /// </summary>
        /// <param name="surveyId">The survey id.</param>
        /// <param name="memberId">The member id.</param>
        /// <returns></returns>
        /// <exception cref="SurveyOperationException">Web Survey Service - ASA.Web.Services.SurveyService.SurveyAdapter.GetQuestionAndResponse()</exception>
        public SurveyListModel GetIndividualsResponse(int surveyId, int memberId)
        {
            const string logMethodName = ".GetIndividualsResponse(string surveyId, string surveyQuestionId, string individualId) - ";

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

            SurveyListModel sList;

            try
            {
                var memberAdapter = new AsaMemberAdapter();
                sList = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").GetUserSurveyResults(surveyId, memberAdapter.GetMemberIdFromContext()).ToDomainModel();
            }

            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);
        }