Exemplo n.º 1
0
        public IHttpActionResult Post([FromBody] TipoDeVeiculoDTO model)
        {
            bool success;

            try
            {
                var entity = new TipoDeVeiculo()
                {
                    Id = Guid.NewGuid(), Tipo = model.Tipo
                };
                success = _service.Insert(entity);
                if (success)
                {
                    return(Ok(convertToDTO(entity)));
                }
                else
                {
                    return(InternalServerError(new Exception("Não foi possível incluir registro.")));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult Put(Guid id, [FromBody] TipoDeVeiculoDTO model)
        {
            bool success;

            try
            {
                var entity = new TipoDeVeiculo()
                {
                    Id = id, Tipo = model.Tipo
                };
                success = _service.Update(id, entity);
                return(Ok(success));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }