예제 #1
0
 private static ReferralHotelProfile ToDomain(ReferralHotelProfileEntity entity)
 => new ReferralHotelProfile
 {
     ReferralHotelId = entity.ReferralHotelId,
     Email           = entity.Email,
     PhoneNumber     = entity.PhoneNumber,
     Name            = entity.Name
 };
예제 #2
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;
        }