public static ProfileAddress ProfileAddress(Profile profile, Address address, AddressType addressType, string createdBy, DateTime created, string updatedBy, DateTime updated)
        {
            ProfileAddress objProfileAddress = new ProfileAddress();

            //Set values for Address
            objProfileAddress.Created = created;
            objProfileAddress.CreatedBy = createdBy;
            objProfileAddress.Updated = updated;
            objProfileAddress.UpdatedBy = updatedBy;

            //Associate Profile for this Profile Phone
            objProfileAddress.ProfileId = profile.ProfileId;

            //Associate Address for this Profile Phone
            objProfileAddress.AddressId = address.AddressId;

            //Associate AddressTye for this Profile Phone
            objProfileAddress.AddressTypeId = addressType.AddressTypeId;

            return objProfileAddress;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save Profile Address
        /// </summary>
        /// <param name="profileAddress"></param>
        void SaveProfileAddress(ProfileAddress profileAddress)
        {
            var entityValidator = EntityValidatorFactory.CreateValidator();

            if (entityValidator.IsValid(profileAddress))//if entity is valid save.
            {
                //add profile address and commit changes
                _profileAddressRepository.Add(profileAddress);
                _profileAddressRepository.UnitOfWork.Commit();
            }
            else // if not valid throw validation errors
                throw new ApplicationValidationErrorsException(entityValidator.GetInvalidMessages(profileAddress));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Delete profile address
        /// </summary>
        /// <param name="profileId"></param>
        public void DeleteProfileAddress(ProfileAddress profileAddress)
        {
            var address = _addressRepository.Get(profileAddress.AddressId);
            //var address = profileAddress;

            if (address != null) //if address exist
            {
                _profileAddressRepository.Remove(profileAddress);
                //commit changes
                _profileAddressRepository.UnitOfWork.Commit();

                _addressRepository.Remove(address);
                //commit changes
                _addressRepository.UnitOfWork.Commit();
            }
            else //the customer not exist, cannot remove
                LoggerFactory.CreateLog().LogWarning(LocalizerFactory.CreateLocalizer().GetString("warning_CannotRemoveNonExistingProfile", typeof(ApplicationErrors)));
        }