Пример #1
0
        /// <summary>
        /// Add new phone
        /// </summary>
        /// <param name="phoneDTO"></param>
        /// <param name="profile"></param>
        private void SavePhone(PhoneDTO phoneDTO, Profile profile)
        {
            if (phoneDTO == null)
            {
                throw new ArgumentException(Messages.warning_CannotAddProfileWithNullInformation);
            }

            // Create a new Phone entity
            Phone phone = PhoneFactory.CreatePhone(phoneDTO.Number, "Anand", DateTime.Now, "Anand", DateTime.Now);

            phone = SavePhone(phone);

            PhoneType phoneType = _phoneTypeRepository.Get(phoneDTO.PhoneTypeId);

            // Create a new ProfilePhone entity
            ProfilePhone profilePhone = ProfilePhoneFactory.CreateProfilePhone(profile, phone, phoneType, "Anand", DateTime.Now, "Anand", DateTime.Now);

            SaveProfilePhone(profilePhone);
        }
Пример #2
0
        /// <summary>
        /// Add new phone
        /// </summary>
        /// <param name="phoneDTO"></param>
        /// <param name="profile"></param>
        void SavePhone(PhoneDTO phoneDTO, Profile profile)
        {
            //if phoneDTO data is not valid
            if (phoneDTO == null)
            {
                throw new ArgumentException(Messages.warning_CannotAddProfileWithNullInformation);
            }

            //Create a new Phone entity
            var newPhone = PhoneFactory.CreatePhone(phoneDTO.Number, "Anand", DateTime.Now, "Anand", DateTime.Now);

            //Save new Phone
            newPhone = SavePhone(newPhone);

            var phoneType = _phoneTypeRepository.Get(phoneDTO.PhoneTypeId);

            //Create a new Profile Phone entity
            var newProfilePhone = ProfilePhoneFactory.CreateProfilePhone(profile, newPhone, phoneType, "Anand", DateTime.Now, "Anand", DateTime.Now);

            //Save new Profile Phone
            SaveProfilePhone(newProfilePhone);
        }