public FileResult ExportExamination(int examinationId, string fileExtension) { logService.LogManually("Export", "Examination", targetId: examinationId, controller: "ExaminationAPI", method: "ExportExamination", fullname: User.Get(u => u.FullName), usercode: User.Get(u => u.Code)); ExaminationViewModel exam = examinationService.GetExanById(examinationId); string fileName = exam.Course.Code + "_" + exam.ExamGroup + "_" + exam.ExamCode + "_" + DateTime.Now.ToString("yyyyMMdd"); List <QuestionInExamViewModel> questions = new List <QuestionInExamViewModel>(); foreach (var part in exam.PartOfExam) { questions = questions.Concat(part.Question).ToList(); } if (fileExtension.ToLower().Equals("xml")) { byte[] byteArray = ExportToXMLFile(questions); return(File(byteArray, System.Net.Mime.MediaTypeNames.Application.Octet, fileName + ".xml")); } else { byte[] byteArray = ExportToGIFTFile(questions); return(File(byteArray, System.Net.Mime.MediaTypeNames.Application.Octet, fileName + ".txt")); } }