public HttpResponseMessage Put(int id, CatServiciosCLS catserviciosCLS) { try { id = catserviciosCLS.cats_id; using (steujedo_sindicatoEntities db = new steujedo_sindicatoEntities()) { Cat_Servicios cat_servicio = db.Cat_Servicios.Where(p => p.cats_id.Equals(id)).First(); if (cat_servicio == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Servicio no encontrado")); } else { cat_servicio.cats_descrip = catserviciosCLS.cats_descrip; cat_servicio.cats_status = catserviciosCLS.cats_status; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Post(string Usuario, CatServiciosCLS catserviciosCLS) { try { using (steujedo_sindicatoEntities db = new steujedo_sindicatoEntities()) { Cat_Servicios catservicios = new Cat_Servicios(); catservicios.cats_descrip = catserviciosCLS.cats_descrip; catservicios.cats_status = catserviciosCLS.cats_status; catservicios.cats_u_captura = Usuario; catservicios.cats_f_captura = DateTime.Now; db.Cat_Servicios.Add(catservicios); db.SaveChanges(); var Mensaje = Request.CreateResponse(HttpStatusCode.Created, catserviciosCLS); return(Mensaje); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }