예제 #1
0
파일: Mapping.cs 프로젝트: vanan08/net_cms
 public static AddressDTO AddressToAddressDTO(Address address)
 {
     AddressDTO objAddressDTO = new AddressDTO();
     if (address != null)
     {
         objAddressDTO.AddressId = address.AddressId;
         objAddressDTO.AddressLine1 = address.AddressLine1;
         objAddressDTO.AddressLine2 = address.AddressLine2;
         objAddressDTO.ZipCode = address.ZipCode;
         objAddressDTO.Country = address.Country;
         objAddressDTO.State = address.State;
         objAddressDTO.City = address.City;
     }
     return objAddressDTO;
 }
예제 #2
0
        /// <summary>
        /// Add new address
        /// </summary>
        /// <param name="addressDTO"></param>
        /// <param name="profile"></param>
        void SaveAddress(AddressDTO addressDTO, Profile profile)
        {
            //if addressDTO data is not valid
            if (addressDTO == null)
                throw new ArgumentException(Messages.warning_CannotAddProfileWithNullInformation);

            //Create a new Address entity
            var newAddress = AddressFactory.CreateAddress(addressDTO.AddressLine1, addressDTO.AddressLine2, addressDTO.City, addressDTO.State, addressDTO.Country,
                                                          addressDTO.ZipCode, "Anand", DateTime.Now, "Anand", DateTime.Now);
            //Save new Address
            SaveAddress(newAddress);

            var addressType = _addressTypeRepository.Get(addressDTO.AddressTypeId);

            //Create a new Profile Address entity
            var newProfileAddress = ProfileAddressFactory.ProfileAddress(profile, newAddress, addressType, "Anand", DateTime.Now, "Anand", DateTime.Now);

            //Save new Address
            SaveProfileAddress(newProfileAddress);
        }