コード例 #1
0
ファイル: Mapping.cs プロジェクト: vanan08/net_cms
        public static ProfileDTO ProfileToProfileDTO(Profile profile, List<AddressType> addressTypes, List<PhoneType> phoneTypes)
        {
            ProfileDTO objProfileDTO = new ProfileDTO();
            objProfileDTO.ProfileId = profile.ProfileId;
            objProfileDTO.FirstName = profile.FirstName;
            objProfileDTO.LastName = profile.LastName;
            objProfileDTO.Email = profile.Email;
            objProfileDTO.AddressDTO = new List<AddressDTO>();
            objProfileDTO.PhoneDTO = new List<PhoneDTO>();

            foreach (var profileAddress in profile.ProfileAddresses)
            {
                AddressDTO objAddressDTO = AddressToAddressDTO(profileAddress.Address);
                objAddressDTO.AddressTypeId = profileAddress.AddressTypeId;
                objProfileDTO.AddressDTO.Add(objAddressDTO);
            }

            foreach (var profilePhone in profile.ProfilePhones)
            {
                PhoneDTO objPhoneDTO = PhoneToPhoneDTO(profilePhone.Phone);
                objPhoneDTO.PhoneTypeId = profilePhone.PhoneTypeId;
                objProfileDTO.PhoneDTO.Add(objPhoneDTO);
            }
            return objProfileDTO;
        }
コード例 #2
0
        /// <summary>
        /// Update existing profile
        /// </summary>
        /// <param name="id"></param>
        /// <param name="profileDTO"></param>
        public void UpdateProfileInformation(int id, ProfileDTO profileDTO)
        {
            //if profileDTO data is not valid
            if (profileDTO == null)
                throw new ArgumentException(Messages.warning_CannotAddProfileWithNullInformation);

            //Create a new profile entity
            var currentProfile = _profileRepository.Get(id);

            //Assign updated value to existing profile
            var updatedProfile = new Profile();
            updatedProfile.ProfileId = id;
            updatedProfile.FirstName = profileDTO.FirstName;
            updatedProfile.LastName = profileDTO.LastName;
            updatedProfile.Email = profileDTO.Email;

            //Update Profile
            updatedProfile = this.UpdateProfile(currentProfile, updatedProfile);

            //Update Address
            List<AddressDTO> lstUpdatedAddressDTO = profileDTO.AddressDTO;
            List<ProfileAddress> lstCurrentAddress = _profileAddressRepository.GetFiltered(x => x.ProfileId.Equals(id)).ToList();

            UpdateAddress (lstUpdatedAddressDTO, lstCurrentAddress, updatedProfile);

            //Update Phone
            List<PhoneDTO> lstUpdatedPhoneDTO = profileDTO.PhoneDTO;
            List<ProfilePhone> lstCurrentPhone = _profilePhoneRepository.GetFiltered(x => x.ProfileId.Equals(id)).ToList();

            UpdatePhone(lstUpdatedPhoneDTO, lstCurrentPhone, updatedProfile);
        }
コード例 #3
0
        /// <summary>
        /// Add new profile
        /// </summary>
        /// <param name="profileDTO"></param>
        /// <returns></returns>
        public void SaveProfileInformation(ProfileDTO profileDTO)
        {
            //if profileDTO data is not valid
            if (profileDTO == null)
                throw new ArgumentException(Messages.warning_CannotAddProfileWithNullInformation);

            //Create a new profile entity
            var newProfile = ProfileFactory.CreateProfile(profileDTO.FirstName, profileDTO.LastName, profileDTO.Email, "Anand", DateTime.Now, "Anand", DateTime.Now);

            //Save Profile
            newProfile = SaveProfile(newProfile);

            //if profileDTO contains any address
            if (profileDTO.AddressDTO != null)
            {
                foreach (AddressDTO objAddressDTO in profileDTO.AddressDTO)
                {
                    this.SaveAddress(objAddressDTO, newProfile);
                }
            }

            //if profileDTO contains any phone
            if (profileDTO.PhoneDTO != null)
            {
                foreach (PhoneDTO objPhoneDTO in profileDTO.PhoneDTO)
                {
                    this.SavePhone(objPhoneDTO, newProfile);
                }
            }
        }
コード例 #4
0
 public HttpStatusCodeResult UpdateProfileInformation(int id, ProfileDTO profileDTO)
 {
     _contactManager.UpdateProfileInformation(id, profileDTO);
     return new HttpStatusCodeResult(HttpStatusCode.OK);
 }
コード例 #5
0
 public HttpStatusCodeResult SaveProfileInformation(ProfileDTO profileDTO)
 {
     _contactManager.SaveProfileInformation(profileDTO);
     return new HttpStatusCodeResult(HttpStatusCode.OK);
 }
コード例 #6
0
 public ActionResult SaveProfileInformation(ProfileDTO profileDTO)
 {
     _contactManager.SaveProfileInformation(profileDTO);
     return Json(new
     {
         IsSuccess = true
     });
 }