public HttpResponseMessage Incluir(CadEntradaControle model) { var context = new AlvoradaContext(); try { context.CadEntradasControle.Add(model); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage Editar(CadEntradaControle model) { var context = new AlvoradaContext(); try { model.DataAlteracao = DateTime.Now; context.Entry(model).State = EntityState.Modified; context.SaveChanges(); } catch (Exception ex) { throw ex; } return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage Excluir([FromBody] CadEntradaControle obj) { var context = new AlvoradaContext(); try { context.Entry(obj).State = EntityState.Deleted; context.SaveChanges(); } catch (Exception ex) { return(Request.CreateResponse <dynamic>(HttpStatusCode.InternalServerError, new { Error = ex.Message })); } return(Request.CreateResponse(HttpStatusCode.OK)); }