Exemple #1
0
        public LowerPayment PostLowerPaymentOptions(LowerPayment lowerPayment)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(lowerPayment);
            }

            lock (_lockObject)
            {
                SaltServiceAgent.PostLesson3(new Lesson3()
                {
                    LowerPaymentOptions = new List <LowerPayment>()
                    {
                        lowerPayment
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract());
            }

            return(lowerPayment);
        }
Exemple #2
0
        public FasterRepayment PostFasterRepaymentOptions(FasterRepayment fasterRepayment)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(fasterRepayment);
            }

            lock (_lockObject)
            {
                SaltServiceAgent.PostLesson3(new Lesson3()
                {
                    FasterRepaymentOptions = new List <FasterRepayment>()
                    {
                        fasterRepayment
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract());
            }

            return(fasterRepayment);
        }
Exemple #3
0
        public Deferment PostLoanDefermentOptions(Deferment deferment)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(deferment);
            }

            lock (_lockObject)
            {
                SaltServiceAgent.PostLesson3(new Lesson3()
                {
                    DefermentOptions = new List <Deferment>()
                    {
                        deferment
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract());
            }

            return(deferment);
        }
Exemple #4
0
        public bool DeleteLoanType(string loanTypeId, LoanType loanType)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(false);
            }

            lock (_lockObject)
            {
                var loanTypes = SaltServiceAgent.GetUserLesson3Results(lessonUserId.Value, LessonSteps.Lesson3.YourBalance).ToDomainObject().LoanTypes.ToList();
                loanTypes.Remove(loanTypes.First(l => l.Equals(loanType)));

                var result = SaltServiceAgent.PostLesson3(
                    new Lesson3()
                {
                    LoanTypes = new List <LoanType>(loanTypes),
                    User      = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract()).ToDomainObject();
            }

            return(true);
        }
Exemple #5
0
        public SelfReportedLoanListModel SaveSelfReportedLoansWithFileName(string sourceName, Stream file)
        {
            var reader    = new StreamReader(file);
            var fileBytes = Encoding.ASCII.GetBytes(reader.ReadToEnd());
            var userId    = _memberAdapter.GetMemberIdFromContext();

            List <MemberReportedLoanContract> loanList;
            SelfReportedLoanListModel         errorObj = new SelfReportedLoanListModel();

            try
            {
                loanList = SaltServiceAgent.ImportLoanFile(userId, fileBytes, sourceName);

                if (loanList.Count == 0)
                {
                    //return an error message so user knows that loans were not imported
                    errorObj.ErrorList.Add(new ErrorModel("No loans returned"));
                    return(errorObj);
                }
                else
                {
                    return(loanList.FromMemberReportedLoanContractList());
                }
            }
            catch (Exception ex)
            {
                //return error with message from SALT Service
                errorObj.Loans = new List <SelfReportedLoanModel>();
                errorObj.ErrorList.Add(new ErrorModel(ex.Message));
                return(errorObj);
            }
        }
Exemple #6
0
        public Favorite PostFavoritePaymentPlan(Favorite favorite)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(null);
            }

            lock (_lockObject)
            {
                var result = SaltServiceAgent.PostLesson3(
                    new Lesson3()
                {
                    FavoriteRepaymentPlans = new List <Favorite>(SaltServiceAgent.GetUserLesson3Results(lessonUserId.Value, LessonSteps.Lesson3.ReviewYourFavorites).ToDomainObject().FavoriteRepaymentPlans)
                    {
                        favorite
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract()).ToDomainObject();

                return(favorite);
            }
        }
Exemple #7
0
        public LoanType PostLoanType(LoanType loanType)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(null);
            }

            lock (_lockObject)
            {
                var result = SaltServiceAgent.PostLesson3(
                    //add new loanType object to list of LoanType and update lesson
                    new Lesson3()
                {
                    LoanTypes = new List <LoanType>()
                    {
                        loanType
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract()
                    ).ToDomainObject();
            }
            return(loanType);
        }
Exemple #8
0
        public RecurringExpense PostRecurringExpense(RecurringExpense recurringExpense)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue || recurringExpense.Value <= 0)
            {
                return(null);
            }

            lock (_lockObject)
            {
                var result = SaltServiceAgent.PostLesson2(
                    new Lesson2()
                {
                    RecurringExpenses = new List <RecurringExpense>(SaltServiceAgent.GetUserLesson2Results(lessonUserId.Value, LessonSteps.Lesson2.RecurringExpenses)
                                                                    .ToDomainObject()
                                                                    .RecurringExpenses)
                    {
                        recurringExpense
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract()).ToDomainObject();

                return(result.RecurringExpenses.First(re => re.Equals(recurringExpense)));
            }
        }
Exemple #9
0
        public OneTimeExpense PostOneTimeExpense(OneTimeExpense oneTimeExpense)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue || oneTimeExpense.Value <= 0)
            {
                return(null);
            }

            lock (_lockObject)
            {
                var result = SaltServiceAgent.PostLesson2(
                    new Lesson2()
                {
                    OneTimeExpenses = new List <OneTimeExpense>(SaltServiceAgent.GetUserLesson2Results(lessonUserId.Value, LessonSteps.Lesson2.OneTimePurchases)
                                                                .ToDomainObject()
                                                                .OneTimeExpenses)
                    {
                        oneTimeExpense
                    },
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract()).ToDomainObject();

                return(result.OneTimeExpenses.First(oe => oe.Equals(oneTimeExpense)));
            }
        }
Exemple #10
0
        /// <summary>
        /// Delete the specified member from SALT db and ActiveDirectory.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns>bool</returns>
        /// <exception cref="System.Exception">There was an error deleteing Member record</exception>
        public bool DeleteMember(ASAMemberModel member)
        {
            const string logMethodName = ".DeleteMember(ASAMemberModel member) - ";

            Log.Debug(logMethodName + "Begin Method");
            bool result = false;

            //delete SALT db information.
            result = SaltServiceAgent.DeleteUser(Convert.ToInt32(member.MembershipId));
            if (0 == false.CompareTo(result))
            {
                Log.Error(logMethodName + "Error deleting member from SALT DB");
                //when debugging, for some reason it step into the if and highlights this line, but it does not throw the error.
                //if you comment out the the construction of the error then the debugger will not step in here.
                throw new WebFaultException <string>("Failed to delete member", System.Net.HttpStatusCode.BadRequest);
            }

            //delete Active Directory Account.
            try
            {
                result = IntegrationLoader.LoadDependency <ISecurityAdapter>("securityAdapter").DeleteMember(member.Emails[0].EmailAddress);
            }
            catch (Exception ex)
            {
                Log.Error(logMethodName + "Error deleting member from AD", ex);
                throw new WebFaultException <string>("Failed to delete member", System.Net.HttpStatusCode.BadRequest);
            }

            Log.Debug(logMethodName + "End Method");
            return(result);
        }
Exemple #11
0
        public bool DeleteRecurringExpense(string expenseId, RecurringExpense recurringExpense)
        {
            var lessonUserId = GetUserLessonId();

            if (!lessonUserId.HasValue)
            {
                return(false);
            }

            lock (_lockObject)
            {
                var recurringExpenses = SaltServiceAgent.GetUserLesson2Results(lessonUserId.Value, LessonSteps.Lesson2.RecurringExpenses).ToDomainObject().RecurringExpenses.ToList();
                recurringExpenses.Remove(recurringExpenses.First(e => e.Equals(recurringExpense)));

                SaltServiceAgent.PostLesson2(
                    new Lesson2()
                {
                    RecurringExpenses = new List <RecurringExpense>(recurringExpenses),
                    User = new User()
                    {
                        UserId = lessonUserId.Value
                    }
                }.ToDataContract()).ToDomainObject();
            }
            return(true);
        }
Exemple #12
0
        public User CreateUser(User user, string lessonId)
        {
            User lessonUser = new User();
            int  validatedLessonId;
            bool lessonIdIsValid = Int32.TryParse(lessonId, out validatedLessonId);

            if (user.IsValid())
            {
                if (lessonIdIsValid)
                {
                    lock (_lockObject)
                    {
                        lessonUser = SaltServiceAgent.StartUserLesson(user.ToDataContract(validatedLessonId)).ToDomainObject();
                        return(lessonUser);
                    }
                }
                else
                {
                    user.AddError("Invalid lessonId");
                }
            }

            //return invalidated incoming user agumented with errormodel
            return(user);
        }
Exemple #13
0
        public Common.ResultCodeModel DeleteAlert(string alertId)
        {
            var logMethodName = ".DeleteAlert(string alertId) - ";

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

            var result = new Common.ResultCodeModel(0);

            if (IsAlertForPersonLoggedIn(alertId))
            {
                try
                {
                    SaltServiceAgent.DeleteAlert(Convert.ToInt32(alertId));
                    result.ResultCode = 1;
                }

                catch (Exception ex)
                {
                    _log.Error(logMethodName + "ASA.Web.Services.AlertService.AlertAdapter.DeleteAlert(): Exception =>" + ex.ToString());
                    throw new AlertOperationException("Web Alert Service - ASA.Web.Services.AlertService.AlertAdapter.DeleteAlert()", ex);
                }
            }
            else
            {
                _log.Warn(logMethodName + "ASA.Web.Services.AlertService.AlertAdapter.DeleteAlert(): Someone is trying to delete alerts that don't belong to them!");
                result.ErrorList.Add(new ErrorModel("Alert could not be deleted"));
            }

            _log.Debug(logMethodName + "End Method");
            return(result);
        }
Exemple #14
0
        /// <summary>
        /// Deactivates the user.
        /// </summary>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public bool DeactivateUser(string email, string modifierUserName = null)
        {
            int userId = SaltServiceAgent.GetUserByUsername(email).MemberId;

            SaltServiceAgent.DeactivateUser(userId, modifierUserName);
            return(true);
        }
Exemple #15
0
        /// <summary>
        /// Creates the specified member.
        /// </summary>
        /// <param name="member">The member.</param>
        /// <returns></returns>
        public RegistrationResultModel Create(ASAMemberModel member)
        {
            const string logMethodName = ".Create(ASAMemberModel member) - ";

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

            RegistrationResultModel toReturn = null;

            try
            {
                var email        = member.Emails.First().EmailAddress;
                var updateResult = SaltServiceAgent.RegisterUser(member.ToUserRegistrationDataContract());

                toReturn = new RegistrationResultModel()
                {
                    Member       = updateResult.Member.ToDomainObject(),
                    CreateStatus = (MemberUpdateStatus)updateResult.CreateStatus
                };

                //the site membership code will delete the account in active directory
                //if an exception is raised.
                if (toReturn.CreateStatus == MemberUpdateStatus.InvalidOrganization)
                {
                    throw new Exception("The organization entered was invalid");
                }
                else if (toReturn.CreateStatus == MemberUpdateStatus.IncompleteProfile)
                {
                    throw new Exception("The user profile is incomplete");
                }
                else if (toReturn.CreateStatus == MemberUpdateStatus.Failure)
                {
                    throw new Exception("An exception has occured creating the user");
                }
                else if (toReturn.CreateStatus == MemberUpdateStatus.Duplicate)
                {
                    throw new Exception("The user already exists in the system.");
                }
            }
            catch (Exception x)
            {
                Log.Error(string.Format(logMethodName + "Error inserting new Individual record for member: MemberAccountId={0}, Email={1}, StackTrace={2}"
                                        , member.MembershipId != null ? member.MembershipId.ToString() : "null"
                                        , member.Emails != null && member.Emails.Count > 0 && !string.IsNullOrEmpty(member.Emails[0].EmailAddress) ? member.Emails[0].EmailAddress : "null"
                                        , x));
                throw x;
            }

            //Call async Qualtric's Target Audience API
            if (Common.Config.QTA_Process.ToLower() == "on")
            {
                QualtricsTA QTA = new QualtricsTA();
                QTA.CreateUser(toReturn.Member);
            }

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

            return(toReturn);
        }
Exemple #16
0
        public List <RecurringExpense> GetRecurringExpenses()
        {
            var lessonUserId = GetUserLessonId();

            return(!lessonUserId.HasValue
                       ? null
                       : SaltServiceAgent.GetUserLesson2Results(lessonUserId.Value)
                   .RecurringExpenses.ToRecurringExpenseDomainObject());
        }
Exemple #17
0
        public User UpdateLesson3User(User user, string userId)
        {
            if (userId == null || string.Empty == userId)
            {
                user.AddError("User ID is undefined!");
                return(user);
            }
            SaltServiceAgent.UpdateUserLesson(user.ToDataContract(LessonTypes.OwnYourStudentLoans));

            return(user);
        }
Exemple #18
0
        public User UpdateLesson2User(User user, string userId)
        {
            if (userId == null || string.Empty == userId)
            {
                user.AddError("User ID is undefined!");
                return(user);
            }
            SaltServiceAgent.UpdateUserLesson(user.ToDataContract(LessonTypes.MasterYourPlastic));

            return(user);
        }
Exemple #19
0
 public bool UpsertMemberRoles(int memberId, List <vMemberRoleModel> memberRoles, string ModifiedBy)
 {
     try
     {
         return(SaltServiceAgent.UpsertMemberRoles(memberId, memberRoles.ToMemberRolesDataContractList().ToArray(), ModifiedBy));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #20
0
 public IEnumerable <vMemberRoleModel> GetMemberRoles(int MemberID)
 {
     try
     {
         return(SaltServiceAgent.GetMemberRoles(MemberID).ToDomainObject());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #21
0
        public SelfReportedLoanModel CreateLoan(SelfReportedLoanModel loan)
        {
            if (!loan.IsValid())
            {
                throw new System.ComponentModel.DataAnnotations.ValidationException();
            }
            var loanContract    = loan.ToMemberReportedLoanContract();
            var userId          = _memberAdapter.GetMemberIdFromContext();
            var serviceResponse = SaltServiceAgent.CreateLoan(userId, loanContract).FromMemberReportedLoanContract();

            return(serviceResponse);
        }
Exemple #22
0
        public IList <MemberOrganizationModel> GetMemberOrganizations(int userId)
        {
            var returnList       = new List <MemberOrganizationModel>();
            var organizationList = SaltServiceAgent.GetMemberOrganizations(userId);

            foreach (var org in organizationList)
            {
                returnList.Add(org.ToMemberOrganizationModel());
            }

            return(returnList);
        }
Exemple #23
0
        public bool DeleteLoan(string id)
        {
            int loanId          = Convert.ToInt32(id);
            var userId          = _memberAdapter.GetMemberIdFromContext();
            var serviceResponse = SaltServiceAgent.DeleteLoan(userId, loanId);

            if (!serviceResponse)
            {
                Log.Debug("End Method");
                throw new WebFaultException <string>("{Failed to delete" + "}", System.Net.HttpStatusCode.BadRequest);
            }
            return(serviceResponse);
        }
Exemple #24
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);
            }
        }
Exemple #25
0
        public IList <MemberProductModel> GetMemberProducts(int memberId)
        {
            var returnList = new List <MemberProductModel>();

            var productList = SaltServiceAgent.GetMemberProducts(memberId);

            foreach (var product in productList)
            {
                returnList.Add(product.ToMemberProductModel());
            }

            return(returnList);
        }
Exemple #26
0
        public bool RetakeLesson(string lessonId)
        {
            var userId = GetUserLessonId();
            var lesson = Convert.ToInt32(lessonId);

            return(userId.HasValue &&
                   SaltServiceAgent.DeleteUserLessonResponses(userId.Value, lesson, null, null, null) &&
                   SaltServiceAgent.UpdateUserLesson(new MemberLessonContract()
            {
                LessonId = lesson,
                CurrentStep = 0,
                LessonUserId = userId.Value
            }));
        }
Exemple #27
0
        public bool UpsertMemberToDo(MemberToDoModel todo)
        {
            bool result;

            try
            {
                result = SaltServiceAgent.UpsertMemberToDo(todo.ToDataContract());
            }
            catch (Exception ex)
            {
                Log.Error("UpsertMemberToDo Exception =>", ex);
                throw;
            }
            return(result);
        }
Exemple #28
0
        /// <summary>
        /// Gets the reminders.
        /// </summary>
        /// <param name="memberId">The member id.</param>
        /// <returns></returns>
        /// <exception cref="ReminderOperationException">Web Reminder Service - ASA.Web.Services.ReminderService.ReminderAdapter.GetReminders()</exception>
        public ReminderListModel GetReminders(int memberId)
        {
            var rList = new ReminderListModel();

            try
            {
                rList = SaltServiceAgent.GetUserPaymentReminders(memberId).ToDomainObject();
            }
            catch (Exception ex)
            {
                _log.Error("ASA.Web.Services.ReminderService.ReminderAdapter.GetReminders(): Exception =>" + ex.ToString());
                throw new ReminderOperationException("Web Reminder Service - ASA.Web.Services.ReminderService.ReminderAdapter.GetReminders()", ex);
            }

            return(rList);
        }
Exemple #29
0
        public bool PostLesson1(Lesson1 lesson1)
        {
            if (lesson1.IsValid())
            {
                lock (_lockObject)
                {
                    SaltServiceAgent.PostLesson1(lesson1.ToDataContract());

                    return(true);
                }
            }
            else
            {
                lesson1.AddError("Lesson object is not valid");
                return(false);
            }
        }
Exemple #30
0
        public IList <MemberToDoModel> GetMemberToDos(int memberID)
        {
            List <MemberToDoModel> returnList = new List <MemberToDoModel>();

            try
            {
                var memberTodoList = SaltServiceAgent.GetMemberToDos(memberID);
                foreach (var todoContract in memberTodoList)
                {
                    returnList.Add(todoContract.ToDomainObject());
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetMemberToDos Exception =>", ex);
            }
            return(returnList);
        }