public bool MakeDecision(string action, int id)
        {
            var applicant = _applicantsRepository.GetSingle(id);

            if (action == "approve")
            {
                applicant.Status = Enums.ApplicantStatus.Approved;
                _applicantsRepository.SaveChanges();

                //Create Member
                var member = _autoMapper.Map <Members>(applicant);
                member.ID           = applicant.ID;
                member.DateCreated  = DateTime.UtcNow;
                member.MembershipID = Helpers.Encorder.Conceal(applicant.ID, 8);


                _memberRepository.Add(member);
                _memberRepository.SaveChanges();

                return(true);
            }
            else
            {
                applicant.Status = Enums.ApplicantStatus.Rejected;
                _applicantsRepository.SaveChanges();

                return(false);
            }
        }
Exemplo n.º 2
0
        public ApplicantsViewModel CreateApplicant(CreateInputModel inputModel)
        {
            var applicantModel = _autoMapper.Map <Applicants>(inputModel);

            applicantModel.PasswordSalt = PasswordEncryptor.CreateSalt(5);

            var hashedPassword = PasswordEncryptor.CreatePasswordHash(applicantModel.Password,
                                                                      applicantModel.PasswordSalt);

            applicantModel.Password = hashedPassword;

            //Get the 2 shareholders
            var shareHolderOne = _memberRepository.FindBy(x => x.MembershipID == inputModel.
                                                          ShareHolder1MemberID).SingleOrDefault();


            var shareHolderTwo = _memberRepository.FindBy(x => x.MembershipID == inputModel.
                                                          ShareHolder2MemberID).SingleOrDefault();

            applicantModel.ShareHolder1ID = shareHolderOne.ID;
            applicantModel.ShareHolder2ID = shareHolderTwo.ID;

            applicantModel.RejectionReason = RejectionReason.Other;

            _applicantRepository.Add(applicantModel);
            _applicantRepository.SaveChanges();

            //Send Email To Applicant
            _emailService.sendEmailToApplicant(applicantModel.EmailAddress, applicantModel.FirstName);

            var applicantViewModel = _autoMapper.Map <ApplicantsViewModel>(applicantModel);

            return(applicantViewModel);
        }