コード例 #1
0
        public IObservable <MpHousehold> UpdateHousehold(MpHousehold household)
        {
            var token       = ApiLogin();
            var asyncresult = Task.Run(() => _ministryPlatformRest.UsingAuthenticationToken(token).Update <MpHousehold>(household));

            return(asyncresult.ToObservable());
        }
コード例 #2
0
        public void SetHouseholdAddress(int contactId, int householdId, int addressId)
        {
            var token     = ApiLogin();
            var household = new MpHousehold()
            {
                Address_ID = addressId, Household_ID = householdId
            };

            _ministryPlatformRest.UsingAuthenticationToken(token).Update <MpHousehold>(household);
        }
コード例 #3
0
        public void ShouldSetHouseholdCongregation()
        {
            var household = new MpHousehold
            {
                Household_ID    = 1709940,
                Congregation_ID = 21,
                Address_ID      = 2928137
            };
            var result = _fixture.UsingAuthenticationToken(_authToken).Update <MpHousehold>(household);

            Assert.NotNull(result);
        }
コード例 #4
0
        public IObservable <IList <Unit> > SaveProfile(string token, GroupLeaderProfileDTO leader)
        {
            // get the current contact data....
            var currentPerson = _personService.GetLoggedInUserProfile(token);

            currentPerson.CongregationId = leader.Site;
            currentPerson.NickName       = leader.NickName;
            currentPerson.LastName       = leader.LastName;
            currentPerson.EmailAddress   = leader.Email;
            currentPerson.DateOfBirth    = leader.BirthDate.ToShortDateString();
            currentPerson.HouseholdId    = leader.HouseholdId;
            currentPerson.MobilePhone    = leader.MobilePhone;
            currentPerson.AddressId      = leader.AddressId;

            var personDict  = getDictionary(currentPerson.GetContact());
            var userUpdates = currentPerson.GetUserUpdateValues();
            var household   = new MpHousehold
            {
                Address_ID      = currentPerson.AddressId,
                Congregation_ID = currentPerson.CongregationId,
                Home_Phone      = currentPerson.HomePhone,
                Household_ID    = currentPerson.HouseholdId
            };

            try
            {
                userUpdates["User_ID"] = _userRepository.GetUserIdByUsername(leader.OldEmail);
            }
            catch (Exception e)
            {
                throw new Exception($"Unable to find the user account for {leader.OldEmail}", e);
            }

            return(Observable.Zip(
                       Observable.Start(() =>
            {
                _contactRepository.UpdateContact(currentPerson.ContactId, personDict);
                _contactRepository.UpdateHousehold(household);
            }),
                       Observable.Start(() => _userRepository.UpdateUser(userUpdates))));
        }