public async Task <IActionResult> Details(int?id) { int?kandidatId = id; if (User.IsInRole(SD.AdminEndUser) && kandidatId == null) { return(NotFound()); } if (User.IsInRole(SD.CandidatEndUSer)) { kandidatId = await _kandidat.GetIdByEmail(User.Identity.Name); } var kandidat = await _kandidat.GetKandidat((int)kandidatId); if (kandidat == null) { return(NotFound()); } KandidatsAndExams ke = new KandidatsAndExams { Kandidat = kandidat, PolozeniIspiti = await _polaganja.GetCompletedExams((int)kandidatId), NepolozeniIspiti = await _ispit.GetNepolozeniIspiti((int)kandidatId) }; return(View(ke)); }
public async Task <IActionResult> ExportCandidates(string option = null, string search = null) { var candidates = await _kandidati.GetFilteredKandidats(option, search); string[,] data = new string[candidates.Count() + 1, (new KandidatWriteModel()).GetType().GetProperties().Length]; WriteHeader(new KandidatWriteModel(), data); #region writebody int r = 1; foreach (var item in candidates) { //prepare model data var writeModel = new KandidatWriteModel() { Id = item.IdAccaNumber, Department = item.Odeljenje, FullName = $"{item.Ime} {item.Prezime}", Email = item.Email, PassedExamCount = (await _polaganja.GetCompletedExams(item.IdAccaNumber)).Count() }; WriteRow(writeModel, data, r); r++; } #endregion return(await Export(data, $"Students {DateTime.Today.Day}-{DateTime.Today.Month}.xlsx")); }