internal void Update(ReferralHotelProfile referralHotelProfile)
 {
     ReferralHotelId = referralHotelProfile.ReferralHotelId;
     Email           = referralHotelProfile.Email;
     PhoneNumber     = referralHotelProfile.PhoneNumber;
     Name            = referralHotelProfile.Name;
 }
Example #2
0
        public async Task <ReferralHotelProfileErrorCodes> UpdateAsync(ReferralHotelProfile referralHotelProfile)
        {
            var result = await _referralHotelProfileRepository.UpdateAsync(referralHotelProfile);

            if (result == ReferralHotelProfileErrorCodes.None)
            {
                _log.Info("Referral hotel profile updated",
                          context: $"referralHotelId: {referralHotelProfile.ReferralHotelId}");
            }
            else
            {
                _log.Info("An error occurred while updating referral hotel profile",
                          context: $"referralHotelId: {referralHotelProfile.ReferralHotelId}; error: {result}");
            }

            return(result);
        }
Example #3
0
        public async Task<ReferralHotelProfileErrorCodes> UpdateAsync(ReferralHotelProfile referralHotelProfile)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.ReferralHotelProfiles.FindAsync(referralHotelProfile.ReferralHotelId);

                if (entity == null)
                    return ReferralHotelProfileErrorCodes.ReferralHotelProfileDoesNotExist;

                _encryptionService.Decrypt(entity);

                entity.Update(referralHotelProfile);

                _encryptionService.Encrypt(entity);

                await context.SaveChangesAsync();
            }

            return ReferralHotelProfileErrorCodes.None;
        }
Example #4
0
        public async Task<ReferralHotelProfileErrorCodes> InsertAsync(ReferralHotelProfile referralHotelProfile)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var entity = await context.ReferralHotelProfiles.FindAsync(referralHotelProfile.ReferralHotelId);

                if (entity != null)
                    return ReferralHotelProfileErrorCodes.ReferralHotelProfileAlreadyExists;

                entity = new ReferralHotelProfileEntity(referralHotelProfile);

                entity = _encryptionService.Encrypt(entity);

                context.ReferralHotelProfiles.Add(entity);

                await context.SaveChangesAsync();
            }
            
            return ReferralHotelProfileErrorCodes.None;
        }
 public ReferralHotelProfileEntity(ReferralHotelProfile referralHotelProfile)
 {
     Update(referralHotelProfile);
 }