Example #1
0
 public async Task <ReglaAlertaOutput> Execute(Guid id, int gestion, string descripcion, decimal porcentaje, string operador, decimal monto)
 {
     if (id == null || id == Guid.Empty)
     {
         await _reglaAlertaWriteOnlyRepository.Add(new ReglaAlerta(gestion, descripcion, porcentaje, new CondicionAlerta(operador), monto));
     }
     else
     {
         await _reglaAlertaWriteOnlyRepository.Update(ReglaAlerta.Load(id, gestion, descripcion, porcentaje, new CondicionAlerta(operador), monto));
     }
     return(new ReglaAlertaOutput(id, gestion, descripcion, porcentaje, operador, monto));
 }
Example #2
0
        public async Task <ReglaAlerta> Get(Guid id)
        {
            using (IDbConnection db = new SqlConnection(connectionString))
            {
                string sqlCommand = "SELECT * FROM ReglasAlerta WHERE ID = @id";

                var reglaAlerta = await db.QueryFirstOrDefaultAsync <Entities.ReglaAlerta>(sqlCommand, new { id });

                if (reglaAlerta == null)
                {
                    return(null);
                }
                var condicion = new CondicionAlerta(reglaAlerta.Operador);
                return(ReglaAlerta.Load(reglaAlerta.ID, reglaAlerta.Gestion, reglaAlerta.Descripcion, reglaAlerta.Porcentaje, condicion, reglaAlerta.Monto));
            }
        }
Example #3
0
        public async Task <ICollection <ReglaAlerta> > GetByGestion(int gestion)
        {
            using (IDbConnection db = new SqlConnection(connectionString))
            {
                string sqlCommand = "SELECT * FROM ReglasAlerta WHERE Gestion = @gestion";

                var reglas = await db.QueryAsync <Entities.ReglaAlerta>(sqlCommand, new { gestion });

                var outputResult = new List <ReglaAlerta>();

                if (reglas == null)
                {
                    return(outputResult);
                }

                foreach (var reglaAlerta in reglas)
                {
                    var condicion = new CondicionAlerta(reglaAlerta.Operador);
                    outputResult.Add(ReglaAlerta.Load(reglaAlerta.ID, reglaAlerta.Gestion, reglaAlerta.Descripcion, reglaAlerta.Porcentaje, condicion, reglaAlerta.Monto));
                }
                return(outputResult);
            }
        }