I've been able to fetch all dates from the database. However, I would like to search through a specific ID that is logged into the system. Per session, in case. But this code is giving error in the part where I put the HttpContext. Any suggestions on what to change?
public static Dictionary<object, object> SelecionaLinhasBancoLista()
{
Dictionary<object, object> dic = new Dictionary<object, object>();
string sql = "";
sql = "SELECT dayname(carrinho.Data), count(day(carrinho.Data)) as quantidade FROM foodintime.carrinho where carrinho.restauranteid = "+ HttpContext.Current.Session["ID"] +"group by day(carrinho.Data)";
using (var ctx = new Context())
using (var cmd = ctx.Database.Connection.CreateCommand())
{
ctx.Database.Connection.Open();
cmd.CommandText = sql;
using (var reader = cmd.ExecuteReader())
{
var model = Read(reader).ToList();
string[] dias = new string[] { "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo" };
foreach (var item in model)
{
dic.Add(item.GetValue(0), item.GetValue(1));
}
}
}