Ejemplo n.º 1
0
        public IActionResult Update(int id, [FromBody] CompanyDTO companyDTO)
        {
            var company = new Company(companyDTO.FantasyName);

            if (company.AddDocument(companyDTO.DocumentValue, companyDTO.DocumentType) &&
                company.AddFederativeUnit(companyDTO.FederativeUnit))
            {
                _companyRepository.Update(id, company);

                return(NoContent());
            }

            return(BadRequest("Unexpected company format."));
        }
Ejemplo n.º 2
0
        public IActionResult Create([FromBody] CompanyDTO companyDTO)
        {
            var company = new Company(companyDTO.FantasyName);

            if (company.AddDocument(companyDTO.DocumentValue, companyDTO.DocumentType) &&
                company.AddFederativeUnit(companyDTO.FederativeUnit))
            {
                var c = _companyRepository.Create(company);

                return(CreatedAtRoute("GetCompany", new { Id = c.CompanyId }));
            }

            return(BadRequest("Unexpected company format."));
        }