feat: Controladores con operaciones CRUD completas
This commit is contained in:
		
							
								
								
									
										29
									
								
								backend/Helpers/HistorialHelper.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								backend/Helpers/HistorialHelper.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | ||||
| using Dapper; | ||||
| using Inventario.API.Data; | ||||
| using Inventario.API.Models; | ||||
|  | ||||
| namespace Inventario.API.Helpers | ||||
| { | ||||
|   public static class HistorialHelper | ||||
|   { | ||||
|     public static async Task RegistrarCambios(DapperContext context, int equipoId, Dictionary<string, (string anterior, string nuevo)> cambios) | ||||
|     { | ||||
|       var query = @"INSERT INTO dbo.historial_equipos (equipo_id, campo_modificado, valor_anterior, valor_nuevo)  | ||||
|                           VALUES (@EquipoId, @CampoModificado, @ValorAnterior, @ValorNuevo);"; | ||||
|  | ||||
|       using (var connection = context.CreateConnection()) | ||||
|       { | ||||
|         foreach (var cambio in cambios) | ||||
|         { | ||||
|           await connection.ExecuteAsync(query, new | ||||
|           { | ||||
|             EquipoId = equipoId, | ||||
|             CampoModificado = cambio.Key, | ||||
|             ValorAnterior = cambio.Value.anterior, | ||||
|             ValorNuevo = cambio.Value.nuevo | ||||
|           }); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user