Beispiel #1
0
        public void MapTo_Professional_To_ProfessionalPoco()
        {
            var entity = new Professional
            {
                Address        = new Address("Rua de teste", "123", "Complement", new ZipCode("12345678")),
                ProfessionalId = 1,
                Code           = Guid.NewGuid(),
                Email          = "*****@*****.**",
                Name           = "Professional",
                Specialties    = new List <Specialty>
                {
                    new Specialty {
                        Id = 1, Description = "Especialidade"
                    }
                }
            };

            var mappPoco = entity.MapTo <ProfessionalPoco>();

            Assert.NotNull(mappPoco);
            Assert.Equal(entity.ProfessionalId, mappPoco.ProfessionalId);
            Assert.Equal(entity.Code, mappPoco.Code);
            Assert.Equal(entity.Name, mappPoco.Name);
            Assert.Equal(entity.Email, mappPoco.Email);
            Assert.Equal(entity.Phone, mappPoco.Phone);
            Assert.NotNull(mappPoco.Address);
            Assert.Equal(entity.Address.Complement, mappPoco.AddressComplement);
            Assert.Equal(entity.Address.Number, mappPoco.AddressNumber);
            Assert.Equal(entity.Address.Street, TextHelper.ToTitleCase(mappPoco.Address));
            Assert.Equal(entity.Address.ZipCode.Number, mappPoco.ZipCode);
            Assert.Null(mappPoco.ProfessionalSpecialties);
        }
Beispiel #2
0
        public void UpdateProfessional(Professional entity)
        {
            var mappedEntity = GetProfessionalPoco(new RequestDto <ComposeKey <Guid, decimal> >(new ComposeKey <Guid, decimal>(entity.Code, entity.ProfessionalId)));

            entity.MapTo(mappedEntity);

            Context.Professionals.Update(mappedEntity);

            Context.SaveChanges();
        }
Beispiel #3
0
        public ComposeKey <Guid, decimal> CreateProfessional(Professional entity)
        {
            var dbEntity = entity.MapTo <ProfessionalPoco>();

            Context.Professionals.Add(dbEntity);

            Context.SaveChanges();

            return(new ComposeKey <Guid, decimal>(dbEntity.Code, dbEntity.ProfessionalId));
        }