示例#1
0
 public void Update(MyPharmacy entity)
 {
     using (DataContext _context = new DataContext())
     {
         _context.Update(PharmacyMapper.MapPharmacyEntityToPharmacyPersistence(entity));
         _context.SaveChanges();
     }
 }
示例#2
0
        public void Map_pharmacy_persistence_to_pharmacy_entity()
        {
            PharmacyPersistence pharmacyPersistence = this.GetPharmacyPersistence();

            MyPharmacy pharmacy = PharmacyMapper.MapPharmacyPersistenceToPharmacyEntity(pharmacyPersistence);

            Assert.True(IsEqualPharmacyPersistanceAndPharmacyEntity(pharmacyPersistence, pharmacy));
        }
示例#3
0
        public Guid Create(PharmacyDTO entityDTO)
        {
            MyPharmacy pharmacy = CreatePharmacyFromDTO(entityDTO);

            _pharmacyRepository.Create(pharmacy);

            return(pharmacy.ApiKey);
        }
示例#4
0
        public static PharmacyPersistence MapPharmacyEntityToPharmacyPersistence(MyPharmacy pharmacy)
        {
            if (pharmacy == null)
            {
                return(null);
            }

            PharmacyPersistence retVal = new PharmacyPersistence()
            {
                ApiKey = pharmacy.ApiKey,
                Name   = pharmacy.Name,
                Url    = pharmacy.Url
            };

            return(retVal);
        }
示例#5
0
        private IdentifiableDTO <PharmacyDTO> CreateDTOFromPharmacy(MyPharmacy pharmacy)
        {
            if (pharmacy == null)
            {
                return(null);
            }

            return(new IdentifiableDTO <PharmacyDTO>()
            {
                Id = pharmacy.ApiKey,
                EntityDTO = new PharmacyDTO()
                {
                    ApiKey = pharmacy.ApiKey,
                    Name = pharmacy.Name,
                    Url = pharmacy.Url
                }
            });
        }
示例#6
0
        private bool ComparePharmacyAndIdentifierPharmacy(MyPharmacy pharmacy, IdentifiableDTO <PharmacyDTO> identifierPharmacy)
        {
            if (pharmacy.ApiKey != identifierPharmacy.EntityDTO.ApiKey)
            {
                return(false);
            }

            if (!pharmacy.Name.Equals(identifierPharmacy.EntityDTO.Name))
            {
                return(false);
            }


            if (!pharmacy.Url.Equals(identifierPharmacy.EntityDTO.Url))
            {
                return(false);
            }

            return(true);
        }
示例#7
0
        public bool IsEqualPharmacyPersistanceAndPharmacyEntity(IdentifiableDTO <PharmacyDTO> pharmacyDTO, MyPharmacy pharmacy)
        {
            if (pharmacy.ApiKey != pharmacyDTO.Key)
            {
                return(false);
            }

            if (!pharmacy.Name.Equals(pharmacyDTO.EntityDTO.Name))
            {
                return(false);
            }

            if (!pharmacy.Url.Equals(pharmacyDTO.EntityDTO.Url))
            {
                return(false);
            }

            return(true);
        }
示例#8
0
        private bool IsEqualPharmacyPersistanceAndPharmacyEntity(PharmacyPersistence pharmacyPersistence, MyPharmacy pharmacy)
        {
            if (pharmacy.ApiKey != pharmacyPersistence.ApiKey)
            {
                return(false);
            }

            if (!pharmacy.Name.Equals(pharmacyPersistence.Name))
            {
                return(false);
            }

            if (!pharmacy.Url.Equals(pharmacyPersistence.Url))
            {
                return(false);
            }


            return(true);
        }
示例#9
0
 public static IdentifiableDTO <PharmacyDTO> MapPhamracyEntityToPharmacyIdentifierDTO(MyPharmacy pharmacy)
 => pharmacy == null ? throw new ArgumentNullException()
                               : new IdentifiableDTO <PharmacyDTO>
 {
     EntityDTO = new PharmacyDTO()
     {
         ApiKey = pharmacy.ApiKey,
         Name   = pharmacy.Name,
         Url    = pharmacy.Url
     }
 };