Exemplo n.º 1
0
        public async Task <ActionResult> put(Int32 id, [FromBody] ThCliente valor)
        {
            try
            {
                if (id != valor.IdCliente)
                {
                    return(BadRequest());
                }

                _context.Entry(valor).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Post([FromBody] ThCliente entity)
        {
            try
            {
                await _context.ThClientes.AddAsync(entity);

                await _context.SaveChangesAsync();

                return(new CreatedAtRouteResult("GetbyId", new
                {
                    id = entity.IdCliente,
                    entity
                }));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }