public async Task <IActionResult> RemoveConta(string username) { historicoHandling.removeHistorico(username); utilizadorHandling.removeUtilizador(username); await HttpContext.SignOutAsync(); return(RedirectToAction("Index", "Home")); }
public IActionResult GetHistorico(string username, string remove) { if (remove == "true") { historicoHandling.removeHistorico(username); } Historico[] his = historicoHandling.getHistorico(username); var map = new Dictionary<int, int>(); foreach (Historico h in his) { if (!map.ContainsKey(h.idReceita)) { if (h.NrPasso == 1 || h.NrPasso == 2) map.Add(h.idReceita, 1); } else { if (h.NrPasso == 1 || h.NrPasso == 2) map[h.idReceita]++; } } Dictionary<Receita, int> mapreceita = new Dictionary<Receita, int>(); Dictionary<Receita, (double, double)> mapreceitatempo = new Dictionary<Receita, (double, double)>(); Dictionary<int, int>.KeyCollection keyColl = map.Keys; int count = 0; foreach (int i in keyColl) { // numero de vezes Receita r = receitaHandling.getReceita(i); mapreceita.Add(r, map[i]); count += map[i]; // melhor tempo int nr_passos = receitapassoHandling.getNrPassosdaReceita(i); List<int> rpassos = receitapassoHandling.getPassosDaReceita(i); double estimado = getTempoReceita(rpassos); double melhor_tempo = historicoHandling.getMelhorTempoReceita(username, i, nr_passos); var t = (estimado, melhor_tempo); mapreceitatempo.Add(r, t); } HistoricoStat hs = new HistoricoStat(); hs.num_receitas = mapreceita; hs.total_realizadas = count; hs.tempos = mapreceitatempo; return View(hs); }