private void PopulatePersonalInformationExtraFields(PersonalInformationViewModel model)
 {
     model.CentreName    = model.Centre.HasValue ? centresDataService.GetCentreName(model.Centre.Value) : null;
     model.CentreOptions = SelectListHelper.MapOptionsToSelectListItems(
         centresDataService.GetCentresForDelegateSelfRegistrationAlphabetical(),
         model.Centre
         );
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> SubmitedForm([FromBody] PersonalInformationViewModel form)
        {
            string message = "";

            await _bl.Save(form);

            message = "Success";
            return(Json(new { message }));
        }
Ejemplo n.º 3
0
        public IActionResult PersonalInformation()
        {
            var data = TempData.Peek <DelegateRegistrationByCentreData>() !;

            var model = new PersonalInformationViewModel(data);

            ValidatePersonalInformation(model);

            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult Save(PersonalInformationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }
            Person person = Mapper.Map <PersonalInformationViewModel, Person>(model);

            return(RedirectToAction("Index", "AddressInformation"));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> PersonalInformation(PersonalInformationViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                await _profileActionHandler.UpdatePersonalInformation(viewModel);

                return(RedirectToLocal(viewModel.ReturnUrl));
            }

            return(View("PersonalInformation", viewModel));
        }
Ejemplo n.º 6
0
        public ActionResult PersonalInformation(PersonalInformationViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var userToUpdate = this.Mapper.Map <User>(model);
                this.users.Update(userToUpdate);
                return(this.RedirectToAction("Index"));
            }

            return(this.View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Index(PersonalInformationPage currentPage)
        {
            PersonalInformationViewModel model = new PersonalInformationViewModel(currentPage);

            if (Request.IsAjaxRequest())
            {
                return(PartialView(model));
            }

            return(View(model));
        }
Ejemplo n.º 8
0
 public async Task Save(PersonalInformationViewModel viewModel)
 {
     //var personInfo = _mapper.Map<PersonalInformationViewModel, PersonalInformation>(viewModel);
     var personInfo = new PersonalInformation
     {
         Age      = viewModel.PersonalInfo.Age,
         Email    = viewModel.PersonalInfo.Email,
         FullName = viewModel.PersonalInfo.FullName,
         Gender   = viewModel.PersonalInfo.Gender
     };
     await _repository.Save(personInfo);
 }
Ejemplo n.º 9
0
        public ActionResult Index()
        {
            var fields = Fields
                         .Where(field => field.AppliesToPage(PageName.PersonalInformation))
                         .OrderBy(field => field.FieldOrder())
                         .ToList();
            var model = new PersonalInformationViewModel {
                Fields = fields
            };

            return(View(model));
        }
Ejemplo n.º 10
0
        public IActionResult PersonalInformation()
        {
            var data = TempData.Peek <RegistrationData>() !;

            var model = new PersonalInformationViewModel(data);

            SetCentreName(model);

            ValidateEmailAddress(model.Email, model.Centre !.Value);

            return(View(model));
        }
        public void PersonalInformation_constructor_using_data_populates_viewmodel_correctly()
        {
            // Given
            var data = RegistrationDataHelper.SampleRegistrationData();

            // When
            var result = new PersonalInformationViewModel(data);

            // Then
            result.FirstName.Should().Be(data.FirstName);
            result.LastName.Should().Be(data.LastName);
            result.Email.Should().Be(data.Email);
            result.Centre.Should().Be(data.Centre);
        }
Ejemplo n.º 12
0
        public IActionResult PersonalInformation()
        {
            var data = TempData.Peek <DelegateRegistrationData>() !;

            var model = new PersonalInformationViewModel(data);

            PopulatePersonalInformationExtraFields(model);

            // Check this email and centre combination doesn't already exist in case we were redirected
            // back here by the user trying to submit the final page of the form
            ValidateEmailAddress(model);

            return(View(model));
        }
Ejemplo n.º 13
0
        private void ValidateEmailAddress(PersonalInformationViewModel model)
        {
            if (model.Email == null || !model.Centre.HasValue)
            {
                return;
            }

            if (!userService.IsDelegateEmailValidForCentre(model.Email, model.Centre !.Value))
            {
                ModelState.AddModelError(
                    nameof(PersonalInformationViewModel.Email),
                    "A user with this email address is already registered at this centre"
                    );
            }
        }
Ejemplo n.º 14
0
        public IActionResult PersonalInformation(PersonalInformationViewModel model)
        {
            var data = TempData.Peek <DelegateRegistrationByCentreData>() !;

            ValidatePersonalInformation(model);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            data.SetPersonalInformation(model);
            TempData.Set(data);

            return(RedirectToAction("LearnerInformation"));
        }
Ejemplo n.º 15
0
        public ActionResult Index()
        {
            //STORES A LIST OF EDUCATION
            var listOfEducation = PersonalInformation.EducationInfo();
            //STORES A LIST OF WORK EXPERIENCE
            var listOfWorkExperience = PersonalInformation.WorkExperience();
            //EmailSentSuccess HAS TO BE FALSE SO THAT MODAL DOES NOT APPEAR (THE ONE YOU WILL GET ONCE YOU SEND AN EMAIL)
            var viewModel = new PersonalInformationViewModel()
            {
                EmailSentSuccess = false,
                Education        = listOfEducation,
                WorkExperience   = listOfWorkExperience
            };

            return(View(viewModel));
        }
Ejemplo n.º 16
0
        public IActionResult PersonalInformation(PersonalInformationViewModel model)
        {
            var data = TempData.Peek <RegistrationData>() !;

            ValidateEmailAddress(model.Email, model.Centre !.Value);

            if (!ModelState.IsValid)
            {
                SetCentreName(model);
                return(View(model));
            }

            data.SetPersonalInformation(model);
            TempData.Set(data);

            return(RedirectToAction("LearnerInformation"));
        }
        public async Task <IActionResult> Index(string infomessage)
        {
            //set value of infomessage if there is any
            if (infomessage != null)
            {
                ViewBag.infomessage = infomessage;
            }

            //Get education list
            var url = "PersonalInformations";
            List <PersonalInformation> personalInformation = await ApiHelper.GetAllObjects <PersonalInformation>(url);

            //set value of list
            var viewModel = new PersonalInformationViewModel
            {
                PersonalInformations = personalInformation
            };

            return(View(viewModel));
        }
        public void SetPersonalInformation_sets_data_correctly()
        {
            // Given
            var model = new PersonalInformationViewModel
            {
                FirstName = FirstName,
                LastName  = LastName,
                Centre    = CentreId,
                Email     = Email
            };
            var data = new RegistrationData();

            // When
            data.SetPersonalInformation(model);

            // Then
            data.FirstName.Should().Be(FirstName);
            data.LastName.Should().Be(LastName);
            data.Email.Should().Be(Email);
            data.Centre.Should().Be(CentreId);
        }
Ejemplo n.º 19
0
        public async Task UpdatePersonalInformation(PersonalInformationViewModel viewModel)
        {
            await _srvKycManager.ChangeFirstNameAsync(CurrentClientId, viewModel.FirstName, RecordChanger.Client);

            await _srvKycManager.ChangeLastNameAsync(CurrentClientId, viewModel.LastName, RecordChanger.Client);

            await _srvKycManager.ChangeFullNameAsync(CurrentClientId, $"{viewModel.FirstName} {viewModel.LastName}", RecordChanger.Client);

            //update client identity
            var clientAccount =
                await _clientAccountsRepository.GetByIdAsync(CurrentClientId);

            await
            _httpContextAccessor.HttpContext.Authentication.SignOutAsync("ServerCookie",
                                                                         new AuthenticationProperties());

            var identity = await _userManager.CreateUserIdentityAsync(clientAccount.Id, clientAccount.Email, clientAccount.Email);

            await _httpContextAccessor.HttpContext.Authentication.SignInAsync("ServerCookie",
                                                                              new ClaimsPrincipal(identity),
                                                                              new AuthenticationProperties());
        }
Ejemplo n.º 20
0
        public IActionResult PersonalInformation(PersonalInformationViewModel model)
        {
            ValidateEmailAddress(model);

            var data = TempData.Peek <DelegateRegistrationData>() !;

            if (!ModelState.IsValid)
            {
                PopulatePersonalInformationExtraFields(model);
                return(View(model));
            }

            if (data.Centre != model.Centre)
            {
                data.ClearCustomPromptAnswers();
            }

            data.SetPersonalInformation(model);
            TempData.Set(data);

            return(RedirectToAction("LearnerInformation"));
        }
Ejemplo n.º 21
0
        public void PersonalInformationPost_with_existing_user_for_centre_fails_validation()
        {
            // Given
            var duplicateUser = UserTestHelper.GetDefaultDelegateUser();
            var model         = new PersonalInformationViewModel
            {
                FirstName = "Test",
                LastName  = "User",
                Centre    = duplicateUser.CentreId,
                Email     = duplicateUser.EmailAddress
            };

            A.CallTo(() => userService.IsDelegateEmailValidForCentre(model.Email !, model.Centre.Value))
            .Returns(false);

            // When
            var result = controller.PersonalInformation(model);

            // Then
            A.CallTo(() => userService.IsDelegateEmailValidForCentre(model.Email !, model.Centre.Value))
            .MustHaveHappened();
            result.Should().BeViewResult().WithDefaultViewName();
        }
Ejemplo n.º 22
0
        public void PersonalInformationPost_with_existing_user_for_different_centre_is_allowed()
        {
            // Given
            controller.TempData.Set(new DelegateRegistrationData());
            var duplicateUser = UserTestHelper.GetDefaultDelegateUser();
            var model         = new PersonalInformationViewModel
            {
                FirstName = "Test",
                LastName  = "User",
                Centre    = duplicateUser.CentreId + 1,
                Email     = duplicateUser.EmailAddress
            };

            A.CallTo(() => userService.IsDelegateEmailValidForCentre(model.Email !, model.Centre.Value))
            .Returns(true);

            // When
            var result = controller.PersonalInformation(model);

            // Then
            A.CallTo(() => userService.IsDelegateEmailValidForCentre(model.Email !, model.Centre.Value))
            .MustHaveHappened();
            result.Should().BeRedirectToActionResult().WithActionName("LearnerInformation");
        }
 public ActionResult PersonalInformation(PersonalInformationViewModel model)
 {
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 24
0
 private void SetCentreName(PersonalInformationViewModel model)
 {
     model.CentreName = centresDataService.GetCentreName(model.Centre !.Value);
 }
Ejemplo n.º 25
0
 public EmployeePersonalInformationView(PersonalInformationViewModel personalInformation)
 {
     InitializeComponent();
     PersonalInformation = personalInformation;
 }
Ejemplo n.º 26
0
        public ActionResult PersonalInformation(PersonalInformationViewModel model)
        {
            if (model != null && this.ModelState.IsValid)
            {
                var userToUpdate = this.Mapper.Map<User>(model);
                this.users.Update(userToUpdate);
                return this.RedirectToAction("Index");
            }

            return this.View(model);
        }
Ejemplo n.º 27
0
        public async Task <ApplicantResponse> UpdatePersonalInformation(ApiHttpClient apiClient, ApplicantResponse applicantResponse, PersonalInformationViewModel model)
        {
            //set the remaining applicant data by updating it
            var updateParameter = new ApplicantParameter(applicantResponse)
            {
                BirthDate       = model.BirthDate,
                City            = model.City,
                Country         = model.Country,
                Nationality     = model.Nationality,
                Phone           = model.Phone,
                Street          = model.Street,
                TitleBeforeName = model.TitleBeforeName,
                TitleAfterName  = model.TitleAfterName,
                ZipCode         = model.ZipCode,
                Email           = model.Email
            };

            return(await new ApplicantPostRequest(applicantResponse.Id, updateParameter).LoadResult(apiClient));
        }
 public override void SetPersonalInformation(PersonalInformationViewModel model)
 {
     base.SetPersonalInformation(model);
     Alias = model.Alias;
 }
Ejemplo n.º 29
0
        public ActionResult Index(string FullName, string phoneNumber, string email, string password, string profession, string CompanyName, string cAddress, string message)
        {
            //Message
            var body         = "<p>Company: {0} ({1})</p><p>From: {2}</p><p>Looking for a: {3}<p>Phone Number: {4}</p></p><p>Message: {5}</p>";
            var emailMessage = new MailMessage();

            //THE RECIPIENT OF THE EMAIL
            emailMessage.To.Add(new MailAddress("*****@*****.**"));
            //THE SENDERS EMAIL
            emailMessage.From = new MailAddress(email);
            //IF THE SENDER CHOOSES NOT TO WRITE THEIR PHONENUMBER
            if (phoneNumber == "")
            {
                phoneNumber = "Phone number was not specified.";
            }
            //IF THEY CHOSE NOT TO SELECT ANY SPECIFIC PROFESSION
            if (profession == "")
            {
                emailMessage.Subject = "Sent from Abel's Contact Form";
                profession          += "No Profession Selected";
            }
            //IF THEY CHOSE A PROFESSION
            else
            {
                emailMessage.Subject = "Looking for a " + profession;
            }
            //COMPLETING THE BODY STRING WITH ADDED VARIABLES
            emailMessage.Body       = string.Format(body, CompanyName, FullName, email, profession, phoneNumber, message);
            emailMessage.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                //SENDS AN EMAIL FROM SPECIFIED EMAIL-ACCOUNT (PASSWORD IS NEEDED)
                var credential = new NetworkCredential
                {
                    UserName = email,
                    Password = password
                };
                smtp.Credentials = credential;
                //WILL USE GMAIL-HOST IF EMAIL-ACCOUNT CONTAINS THE WORD '@GMAIL.'
                if (email.Contains("@gmail."))
                {
                    smtp.Host = "smtp.gmail.com";
                }
                //IF NOT - WILL USE HOTMAIL.COM
                else
                {
                    smtp.Host = "smtp-mail.outlook.com";
                }
                smtp.Port      = 587;
                smtp.EnableSsl = true;
                smtp.Send(emailMessage);
            }
            //STORES A LIST OF EDUCATION
            var listOfEducation = PersonalInformation.EducationInfo();
            //STORES A LIST OF WORK EXPERIENCE
            var listOfWorkExperience = PersonalInformation.WorkExperience();
            //A CONFIRMATION MODAL WILL APPEAR ONCE THE EMAIL HAS BEEN SENT SUCCESFULLY WITH ALL OF THE INFORMATION UNDERNEATH
            var viewModel = new PersonalInformationViewModel()
            {
                cAddress         = cAddress,
                CompanyName      = CompanyName,
                Email            = email,
                FullName         = FullName,
                Message          = message,
                PhoneNumber      = phoneNumber,
                Profession       = profession,
                EmailSentSuccess = true,
                Education        = listOfEducation,
                WorkExperience   = listOfWorkExperience
            };

            return(View(viewModel));
        }