public HttpResponseMessage Create(SistemaRefaccionesModel area) { SistemaRefacciones acu = new SistemaRefacciones(); try { if (area != null) { acu.IdArea = area.IdArea; acu.NombreSistema = area.NombreSistema; db.SistemaRefacciones.Add(acu); db.SaveChanges(); return(new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = null }); } else { return(new HttpResponseMessage(System.Net.HttpStatusCode.NoContent) { Content = null }); } } catch (Exception ex) { return(Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message + Environment.NewLine + "Area")); } }
public async Task <HttpResponseMessage> PutEventosGuiaInspeccion(SistemaRefaccionesModel id) { using (db = new DBConnection()) { try { SistemaRefacciones tipo = new SistemaRefacciones(); tipo = await db.SistemaRefacciones.Where(x => x.IdSistemaRefacciones == id.IdSistemaRefacciones).FirstOrDefaultAsync().ConfigureAwait(false); if (tipo == null) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } else { tipo.IdArea = id.IdArea; tipo.NombreSistema = id.NombreSistema; await db.SaveChangesAsync(); return(new HttpResponseMessage(HttpStatusCode.OK)); } } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(ex.Message) }); } } }