public IActionResult GetCertificate(long id) { var fileInfo = _context.UserCertificates .Where(x => x.Id == id) .Select(x => x.File) .SingleOrDefault(); var fileStream = _fileWorker.ReadFile(fileInfo.Path); return(File(fileStream, "application/octet-stream", fileInfo.Name)); }
public async Task <IActionResult> Download([FromRoute] long id) { var document = await _context.DocumentTemplates .Where(x => x.Id == id) .Select(x => x.File) .SingleOrDefaultAsync(); var stream = _fileWorker.ReadFile(document.Path); return(File(stream, "application/octet-stream", document.Name)); }
private void upload_Click(object sender, EventArgs e) { try { List <User> users = _fileWorker.ReadFile(); if (users != null) { users.ForEach(user => _userRepository.addUser(user)); } mainForm.ReloadData(); } catch (ArgumentOutOfRangeException) { MessageBox.Show("The file for import is not correct"); } catch (IOException) { MessageBox.Show("the file is already in use or was left open by another application"); } this.Close(); }