Example #1
0
        private static void GetUpdatedPersonFromVm(PersonDetailsVm model, AspNetUser user)
        {
            var person = user.UserPerson;

            SetUserProperties(model, user);
            SetPersonProperties(model, person);
        }
Example #2
0
 private static void SetPersonProperties(PersonDetailsVm model, UserPerson person)
 {
     person.DateOfBirth = model.DateOfBirth.GetValueOrDefault();
     person.AddressLine1 = model.AddressLine1;
     person.AddressLine2 = model.AddressLine2;
     person.Gender = model.Gender;
     person.City = model.City;
 }
Example #3
0
        private void CreateNewPersonFromVm(PersonDetailsVm model, AspNetUser user)
        {
            var person = _personRepository.NewObject();

            SetUserProperties(model, user);
            SetPersonProperties(model, person);

            user.UserPerson = person;
        }
Example #4
0
        public void SavePersonalDetails(PersonDetailsVm model, string userId)
        {
            var user = _userRepository.Single(p => p.Id == userId);

            if (user.UserPerson != null) GetUpdatedPersonFromVm(model, user);
            else CreateNewPersonFromVm(model, user);

            _userRepository.Modify(user);
            _userRepository.SaveChanges();
        }
Example #5
0
 private static void SetUserProperties(PersonDetailsVm model, AspNetUser user)
 {
     user.FirstName = model.FirstName;
     user.LastName = model.LastName;
     user.PhoneNumber = model.Phone;
 }
        public Task<ActionResult> SavePersonalDetails(PersonDetailsVm model)
        {
            if (!ModelState.IsValid) return Index(ManageMessageId.Error);

            try
            {
                _userService.SavePersonalDetails(model, User.Identity.GetUserId());
                _log.Info($"Successfully updated profile of user {User.Identity.Name}");

                return Index(ManageMessageId.UpdatedProfile);
            }
            catch (Exception exception)
            {
                _log.Error(FormatUtility.GetExceptionMessage(exception));
                return Index(ManageMessageId.Error);
            }
        }