public async Task <HttpResponseMessage> GetEventosGuiaInspeccion(IdSistemaRefaccionesModel id) { using (db = new DBConnection()) { try { SistemaRefacciones tipo = new SistemaRefacciones(); tipo = await db.SistemaRefacciones.FindAsync(id.IdSistemaRefacciones); if (tipo == null) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } else { return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(tipo), System.Text.Encoding.UTF8, "application/json") }); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(ex.Message) }); } } }
public async Task <HttpResponseMessage> DeleteEventosGuiaInspeccion(IdSistemaRefaccionesModel id) { using (db = new DBConnection()) { try { SistemaRefacciones tipo = new SistemaRefacciones(); tipo = await db.SistemaRefacciones.FindAsync(id.IdSistemaRefacciones); if (tipo == null) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } else { db.SistemaRefacciones.Remove(tipo); await db.SaveChangesAsync(); return(new HttpResponseMessage(HttpStatusCode.OK)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(ex.Message) }); } } }