Example #1
0
        public async Task <ActionResult> Post([FromBody] PoupancaDto dtoCreate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var result = await _service.Post(dtoCreate);

                if (result != null)
                {
                    return(Ok(result));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (ArgumentException e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
            }
        }
Example #2
0
        public async Task <PoupancaDto> Post(PoupancaDto objeto)
        {
            var model  = _mapper.Map <PoupancaModel>(objeto);
            var entity = _mapper.Map <PoupancaEntity>(model);
            var result = await _repository.InsertAsync(entity);

            return(_mapper.Map <PoupancaDto>(result));;
        }