public SqlOperation GetCreateStatement(BaseEntity entity) { var operacion = new SqlOperation { ProcedureName = "CREAR_PROMOCION" }; var p = (Promocion)entity; operacion.AddVarcharParam(DB_COL_NOMBRE, p.nombre); operacion.AddDoubleParam(DB_COL_PORCENTAJE, p.porcentaje); operacion.AddVarcharParam(DB_COL_CODIGO, p.codigo); operacion.AddIntParam(DB_COL_CANTIDAD, p.cantidad); if (p.id_comercio > 0) { operacion.AddIntParam(DB_COL_ID_COMERCIO, p.id_comercio); } else { operacion.AddNullParam(DB_COL_ID_COMERCIO); } if (p.id_sucursal > 0) { operacion.AddIntParam(DB_COL_ID_SUCURSAL, p.id_sucursal); } else { operacion.AddNullParam(DB_COL_ID_SUCURSAL); } return(operacion); }
public SqlOperation GetUpdateStatement(BaseEntity entity) { var operation = new SqlOperation { ProcedureName = "MODIFICAR_CALIFICACION" }; var c = (Calificacion)entity; operation.AddIntParam(DB_COL_ID, c.Id); operation.AddIntParam(DB_COL_ID_USUARIO, c.UsuarioId); operation.AddIntParam(DB_COL_CALIFICACION, c.Puntaje); if (c.ComercioId == 0) { operation.AddNullParam(DB_COL_ID_COMERCIO); } else { operation.AddIntParam(DB_COL_ID_COMERCIO, c.ComercioId); } if (c.ItemId == 0) { operation.AddNullParam(DB_COL_ID_ITEM); } else { operation.AddIntParam(DB_COL_ID_ITEM, c.ItemId); } return(operation); }
public SqlOperation GetUpdateStatement(BaseEntity entity) { var operation = new SqlOperation { ProcedureName = "MODIFICAR_USUARIO" }; var u = (Usuario)entity; operation.AddIntParam(DB_COL_ID, u.Id); operation.AddVarcharParam(DB_COL_CEDULA, u.Cedula); operation.AddVarcharParam(DB_COL_NOMBRE, u.Nombre); operation.AddVarcharParam(DB_COL_APELLIDO, u.Apellido); operation.AddVarcharParam(DB_COL_CORREO, u.Correo); operation.AddVarcharParam(DB_COL_TELEFONO, u.Telefono); if (u.Foto == null) { operation.AddNullParam(DB_COL_ID_FOTO); } else { operation.AddIntParam(DB_COL_ID_FOTO, u.Foto.Id); } if (u.TelefonoConfirmado == 0) { operation.AddNullParam(DB_COL_TELEFONO_CONFIRMADO); } else { operation.AddIntParam(DB_COL_TELEFONO_CONFIRMADO, u.TelefonoConfirmado); } if (u.CorreoConfirmado == 0) { operation.AddNullParam(DB_COL_CORREO_CONFIRMADO); } else { operation.AddIntParam(DB_COL_CORREO_CONFIRMADO, u.CorreoConfirmado); } if (String.IsNullOrEmpty(u.CodigoTelefono)) { operation.AddNullParam(DB_COL_CODIGO_TELEFONO); } else { operation.AddVarcharParam(DB_COL_CODIGO_TELEFONO, u.CodigoTelefono); } if (String.IsNullOrEmpty(u.CodigoCorreo)) { operation.AddNullParam(DB_COL_CODIGO_CORREO); } else { operation.AddVarcharParam(DB_COL_CODIGO_CORREO, u.CodigoCorreo); } operation.AddIntParam(DB_COL_TIPO, u.Tipo); return(operation); }
public SqlOperation GetRetriveSomeStatement(BaseEntity entity) { var operation = new SqlOperation { ProcedureName = "BUSCAR_USUARIO" }; var u = (Usuario)entity; if (u.Id == 0) { operation.AddNullParam(DB_COL_ID); } else { operation.AddIntParam(DB_COL_ID, u.Id); } if (u.Cedula == null) { operation.AddNullParam(DB_COL_CEDULA); } else { operation.AddVarcharParam(DB_COL_CEDULA, u.Cedula); } if (u.Nombre == null) { operation.AddNullParam(DB_COL_NOMBRE); } else { operation.AddVarcharParam(DB_COL_NOMBRE, u.Nombre); } if (u.Apellido == null) { operation.AddNullParam(DB_COL_APELLIDO); } else { operation.AddVarcharParam(DB_COL_APELLIDO, u.Apellido); } if (u.Correo == null) { operation.AddNullParam(DB_COL_CORREO); } else { operation.AddVarcharParam(DB_COL_CORREO, u.Correo); } if (u.Telefono == null) { operation.AddNullParam(DB_COL_TELEFONO); } else { operation.AddVarcharParam(DB_COL_TELEFONO, u.Telefono); } if (u.Foto.Id == 0) { operation.AddNullParam(DB_COL_ID_FOTO); } else { operation.AddIntParam(DB_COL_ID_FOTO, u.Foto.Id); } if (u.TelefonoConfirmado == 0) { operation.AddNullParam(DB_COL_TELEFONO_CONFIRMADO); } else { operation.AddIntParam(DB_COL_TELEFONO_CONFIRMADO, u.TelefonoConfirmado); } if (u.CorreoConfirmado == 0) { operation.AddNullParam(DB_COL_CORREO_CONFIRMADO); } else { operation.AddIntParam(DB_COL_CORREO_CONFIRMADO, u.CorreoConfirmado); } if (u.CodigoTelefono == null) { operation.AddNullParam(DB_COL_CODIGO_TELEFONO); } else { operation.AddVarcharParam(DB_COL_CODIGO_TELEFONO, u.CodigoTelefono); } if (u.CodigoCorreo == null) { operation.AddNullParam(DB_COL_CODIGO_CORREO); } else { operation.AddVarcharParam(DB_COL_CODIGO_CORREO, u.CodigoCorreo); } if (u.Estado == 0) { operation.AddNullParam(DB_COL_ESTADO); } else { operation.AddIntParam(DB_COL_ESTADO, u.Estado); } if (u.Tipo == 0) { operation.AddNullParam(DB_COL_TIPO); } else { operation.AddIntParam(DB_COL_TIPO, u.Tipo); } return(operation); }