コード例 #1
0
 public UnitOfWork(ImobiliariaContext context)
 {
     _context         = context;
     PhysicalPerson   = new PhysicalPersonRepository(_context);
     LegalEntity      = new LegalEntityRepository(_context);
     ImovelRepository = new ImovelRepository(_context);
 }
コード例 #2
0
 public ImovelRepository(ImobiliariaContext context)
     : base(context)
 {
 }
コード例 #3
0
        protected override void Seed(ImobiliariaContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            var listProprietarios = new List <Proprietario>()
            {
                new Proprietario()
                {
                    Nome           = "Francisco",
                    Email          = "*****@*****.**",
                    DataNascimento = "28/02/1991"
                },

                new Proprietario()
                {
                    Nome           = "Teste2",
                    Email          = "*****@*****.**",
                    DataNascimento = "20/02/1991"
                }
            };


            listProprietarios.ForEach(s => context.GetProprietarios.AddOrUpdate(x => x.Nome, s)
                                      );
            context.SaveChanges();

            var listaImoveis = new List <Imovel>()
            {
                new Imovel()
                {
                    Cep            = "88048301",
                    Bairro         = "Centro",
                    Municipio      = "Blumenau",
                    Complemento    = "casa",
                    Numero         = 20,
                    Logradouro     = "Rua teste",
                    ProprietarioId = context.GetProprietarios.FirstOrDefault(x => x.Nome == "Francisco").Id
                },

                new Imovel()
                {
                    Cep            = "88048300",
                    Bairro         = "Centro",
                    Municipio      = "Blumenau",
                    Complemento    = "casa",
                    Numero         = 20,
                    Logradouro     = "Rua teste2",
                    ProprietarioId = context.GetProprietarios.FirstOrDefault(x => x.Nome == "Teste2").Id
                }
            };

            listaImoveis.ForEach(s => context.GetImovels.AddOrUpdate(x => new { x.ProprietarioId, x.Cep }, s)
                                 );

            context.SaveChanges();

            //context.GetProprietarios.AddOrUpdate(x => x.Nome, new Models.Proprietario()
            //{
            //    Nome = "Francisco",
            //    Email = "*****@*****.**",
            //    DataNascimento = "28/02/1991"
            //});
            //context.GetImovels.AddOrUpdate(x => x.Cep, new Models.Imovel()
            //{
            //    Cep = "88048301",
            //    Bairro = "Centro",
            //    Municipio = "Blumenau",
            //    Complemento = "casa",
            //    Numero = 20,
            //    Logradouro = "Rua teste"

            //});


            //context.SaveChanges();
        }
コード例 #4
0
 public LegalEntityRepository(ImobiliariaContext context)
     : base(context)
 {
 }
コード例 #5
0
 public PhysicalPersonRepository(ImobiliariaContext context)
     : base(context)
 {
 }
コード例 #6
0
 public Repository(ImobiliariaContext context)
 {
     _context = context;
 }