コード例 #1
0
        public HttpResponseMessage Inserir(Cliente cliente)
        {
            try
            {
                _db.Clientes.Add(cliente);
                _db.SaveChanges();

                return Request.CreateResponse(HttpStatusCode.OK, cliente);
            }
            catch (Exception ex)
            {
               return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
            }
        }
コード例 #2
0
        public HttpResponseMessage Alterar(Cliente cliente)
        {
            try
            {
                _db.Entry(cliente).State = EntityState.Modified;
                _db.SaveChanges();
                return Request.CreateResponse(HttpStatusCode.OK, cliente);
            }
            catch (Exception ex)
            {

                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
            }
        }