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"));
        }
Exemple #2
0
        // GET: Kandidats
        public async Task <IActionResult> Index(string option = null, string search = null, string submit = null)
        {
            if (submit == "export")
            {
                return(RedirectToAction("ExportCandidates", "ExcelExport", new { option, search }));
            }
            var kandidats = await _kandidat.GetFilteredKandidats(option, search);

            return(View(kandidats));
        }