Пример #1
0
        public async Task <IActionResult> Incluir(ClienteModel clienteModel)
        {
            var retorno = await _clienteApplication.Incluir(clienteModel);

            if (retorno.Valid)
            {
                return(Ok(retorno.Object));
            }
            return(BadRequest(retorno.Notifications));
        }
Пример #2
0
        public async Task <IHttpActionResult> InserirCliente(Cliente cliente)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                _clienteApplication.Incluir(cliente);

                return(CreatedAtRoute("Default", new { controller = "Cliente", id = cliente.Id }, cliente));
            }
            catch (ApplicationException ex)
            {
                return(new BusinessResult(ex.Message, HttpStatusCode.BadRequest));
            }

            catch (Exception ex)
            {
                return(new BusinessResult(ex.Message, HttpStatusCode.InternalServerError));
            }
        }