public PersonPhysical PostPersonPhysical(PersonPhysical person)
 {
     _personPhysicalRepository.Begin();
     _personPhysicalRepository.Save(person);
     _personPhysicalRepository.Commit();
     return(person);
 }
Esempio n. 2
0
        public void Initialize()
        {
            context.Database.Migrate();

            if (!context.Set <Status>().Any())
            {
                Status[] listStatus = AddStatus();
                context.AddRange(listStatus);
            }

            if (!context.Set <Person>().Any())
            {
                PersonPhysical person = new PersonPhysical();
                person.FullName = "Elvis";
                person.Birth    = DateTime.Now;
                person.Document = "446.866.553-07";

                context.Add(person);

                PersonLegal legal = new PersonLegal();
                legal.FantasyName  = "Solucoes Integradas El";
                legal.SocialReason = "EL Solution";
                legal.Document     = "54.354.255/0001-81";

                context.Add(person);
            }

            if (!context.Set <TransactionsType>().Any())
            {
                TransactionsType[] list = AddTransactionsType();
                context.AddRange(list);
            }

            context.SaveChanges();
        }
Esempio n. 3
0
 public ActionResult <PersonPhysical> PostPersonPhysical(PersonPhysical person, [FromServices] PersonApplication personApplication)
 {
     try
     {
         return(personApplication.PostPersonPhysical(person));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
        public int PostPersonPhysicaORPersonLegal(PersonLegalDTO personLegalDTO, PersonPhysicalDTO personPhysicalDTO)
        {
            if (personLegalDTO != null && personPhysicalDTO != null)
            {
                throw new Exception("Só deve existir uma pessoa para o cadastro continuar!");
            }

            if (personLegalDTO == null && personPhysicalDTO == null)
            {
                throw new Exception("É necessario informar uma pessoa fisica ou juridica para continuar!");
            }

            try
            {
                if (personLegalDTO != null)
                {
                    PersonLegal personLegal = new PersonLegal();
                    personLegal.Document     = personLegalDTO.Document;
                    personLegal.FantasyName  = personLegalDTO.FantasyName;
                    personLegal.SocialReason = personLegalDTO.SocialReason;

                    return(PostPersonLegal(personLegal).Id);
                }
                else
                {
                    PersonPhysical personPhysical = new PersonPhysical();
                    personPhysical.Document = personPhysicalDTO.Document;
                    personPhysical.FullName = personPhysicalDTO.FullName;
                    personPhysical.Birth    = personPhysicalDTO.Birth;

                    return(PostPersonPhysical(personPhysical).Id);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }