internal static TipoDeAgencia Get(TipoDeAgenciaEntity entity) { IMapper mapper; TipoDeAgencia item; mapper = GetMapperEntityToDto(); item = mapper.Map <TipoDeAgencia>(entity); return(item); }
public static void Update(TipoDeAgenciaEntity entity) { try { string query; query = $@"UPDATE tipo_de_agencia SET nombre = @Nombre WHERE id = @Id"; using (var db = new MySqlConnection(Conexion.CadenaDeConexion)) { db.Query <int>(query, new { Nombre = entity.Nombre, Id = entity.Id }); } } catch (Exception) { throw; } }
public static int Add(TipoDeAgenciaEntity entity) { try { string query; query = $@"INSERT INTO tipo_de_agencia (nombre) VALUES (@Nombre); SELECT LAST_INSERT_ID();"; using (var db = new MySqlConnection(Conexion.CadenaDeConexion)) { entity.Id = db.Query <int>(query, new { Nombre = entity.Nombre }).FirstOrDefault(); } return(entity.Id); } catch (Exception) { throw; } }