public async Task <Object []> EliminarValorResolucion(int id_valor_resolucion) { Object [] response = new Object [2]; try { ValorResolucion resolutionValueToDelete = await AppDbContext.valoresResolucion.Where(vr => vr.id_valor_resolucion == id_valor_resolucion).FirstOrDefaultAsync(); List <Resolucion> resoluciones = await AppDbContext.resoluciones.Where(r => r.id_valor_resolucion == resolutionValueToDelete.id_valor_resolucion).ToListAsync(); foreach (Resolucion resolucion in resoluciones) { await EliminarResolucion(resolucion.id_tipo_resolucion, resolucion.id_valor_resolucion, resolucion.id_relacion_aspecto); } AppDbContext.valoresResolucion.Remove(resolutionValueToDelete); await AppDbContext.SaveChangesAsync(); response[0] = true; } catch (Exception exception) { response[1] = (exception.InnerException != null) ? exception.InnerException.Message : exception.Message; } return(response); }
public async Task <Object []> CrearValorResolucion(ValorResolucion valorResolucion) { Object [] response = new Object [2]; try { await AppDbContext.valoresResolucion.AddAsync(valorResolucion); await AppDbContext.SaveChangesAsync(); response[0] = true; } catch (Exception exception) { response[1] = (exception.InnerException != null) ? exception.InnerException.Message : exception.Message; } return(response); }
public async Task <Object []> ActualizarValorResolucion(ValorResolucion valorResolucion) { Object [] response = new Object [2]; try { ValorResolucion resolutionValueToUpdate = await AppDbContext.valoresResolucion.Where(vr => vr.id_valor_resolucion == valorResolucion.id_valor_resolucion).FirstOrDefaultAsync(); resolutionValueToUpdate.valor_resolucion = valorResolucion.valor_resolucion; AppDbContext.valoresResolucion.Update(resolutionValueToUpdate); await AppDbContext.SaveChangesAsync(); response[0] = true; } catch (Exception exception) { response[1] = (exception.InnerException != null) ? exception.InnerException.Message : exception.Message; } return(response); }
public async Task <Object []> UpdateResolutionValueAsync([FromBody] ValorResolucion valorResolucion) { return(await detallesTecnicos.ActualizarValorResolucion(valorResolucion)); }