public async Task Should_Not_Create_Taxpayer_When_CPF_Is_Already_In_Use()
        {
            var taxpayer = new Taxpayer {
                Id = 1, NumberOfDependents = 0, MonthlyGrossIncome = 2000, CPF = 11111111111
            };

            var result = await _taxpayerService.CreateAsync(taxpayer);

            Assert.IsFalse(result.Success);
            Assert.AreEqual("Já existe um usuário na base com o CPF especificado.", result.Message);
        }
        public async Task <IActionResult> CreateAsync([FromBody] SaveTaxpayerResource saveTaxpayerResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var taxpayer = _mapper.Map <SaveTaxpayerResource, Taxpayer>(saveTaxpayerResource);

            var response = await _taxpayerService.CreateAsync(taxpayer);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }

            var resource = _mapper.Map <Taxpayer, TaxpayerResource>(response.Taxpayer);

            return(Ok(resource));
        }