예제 #1
0
        public void EditEmailForCurrentUser(int personId, string email, out string error)
        {
            Trace.Assert(Context.PersonId.HasValue);

            var person = GetPersonDetails(personId);

            if (!person.UserId.HasValue)
            {
                throw new ChalkableSecurityException();
            }

            var    user     = ServiceLocator.ServiceLocatorMaster.UserService.GetBySisUserId(person.UserId.Value, Context.DistrictId);
            string oldEmail = user.Login;

            using (var uow = Update())
            {
                ServiceLocator.ServiceLocatorMaster.UserService.ChangeUserLogin(user.Id, email, out error); //security check here
                if (string.IsNullOrEmpty(error))
                {
                    return;
                }

                var stiPersonEmail = new StiPersonEmail
                {
                    Description  = "",
                    EmailAddress = email,
                    IsListed     = true,
                    IsPrimary    = true,
                    PersonId     = Context.PersonId.Value
                };
                ConnectorLocator.UsersConnector.UpdatePrimaryPersonEmail(stiPersonEmail.PersonId, stiPersonEmail);
                ServiceLocator.ServiceLocatorMaster.EmailService.SendChangedEmailToPerson(person, oldEmail, email);

                uow.Commit();
            }
        }
예제 #2
0
        public void UpdatePrimaryPersonEmail(int personId, StiPersonEmail personEmail)
        {
            var url = $"{BaseUrl}persons/{personId}/emailaddresses/primary";

            Put <Object, StiPersonEmail>(url, personEmail);
        }