public DashboardVM Dashboard(int param) { var sql = RegistroFactory.ToQuery(param); MySqlConnection connection = new MySqlConnection(DbConn.ConnectionString); connection.Open(); MySqlCommand command = new MySqlCommand(sql, connection); command.CommandTimeout = 120; command.CommandType = CommandType.Text; MySqlDataReader reader = command.ExecuteReader(); DashboardVM dashboard = new DashboardVM(); dashboard.Title = "Dashboard" + param; dashboard.Data = new List <DataVM>(); dashboard.Count = 0; if (reader.HasRows) { while (reader.Read()) { DataVM data = new DataVM(); data.Field = reader.GetString(0); data.Count = reader.GetInt32(1); dashboard.Data.Add(data); dashboard.Count = dashboard.Count + data.Count; } } connection.Dispose(); return(dashboard); }
public bool Status(int id, int code) { Agenda agenda = _context.Agendas.Where(a => a.Id_Registro.Equals(id)).FirstOrDefault(); agenda.Status = RegistroFactory.ToStatus(code); Db.Entry(agenda).CurrentValues.SetValues(agenda); Db.Entry(agenda).State = EntityState.Modified; Save(); return(true); }