0% found this document useful (0 votes)
7 views2 pages

Student Form Controller

The document outlines the implementation of a 'StudFormController' in an ASP.NET Core web application, which handles the display and downloading of a student form. It utilizes a template document for generating contracts based on user input, including a formatted date of birth and other details. The controller also includes an error handling method to manage exceptions during the process.

Uploaded by

dayen55024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Student Form Controller

The document outlines the implementation of a 'StudFormController' in an ASP.NET Core web application, which handles the display and downloading of a student form. It utilizes a template document for generating contracts based on user input, including a formatted date of birth and other details. The controller also includes an error handling method to manage exceptions during the process.

Uploaded by

dayen55024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

using System;

using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace [Link]
{

[Area("User")]
public class StudFormController : Controller
{
private readonly IWebHostEnvironment environment;

public StudFormController(IWebHostEnvironment environment)


{
[Link] = environment;
}

public IActionResult StudentForm()


{
return View(new InvoiceModel());
}

public FileStreamResult Download(InvoiceModel model)


{
var tipStudent = [Link];

// Load template document.


var path = [Link]([Link],
"[Link]");
var document = [Link](path);

DateTime dataNasterii = model.Data_nasterii;

string dataNasteriiFormatata = [Link]("dd-MM-yyyy");

[Link](new
{
Data_nasterii = dataNasteriiFormatata

});

// Execute mail merge process.


[Link](model);

// Save document in specified file format.


var stream = new MemoryStream();
[Link](stream, [Link]);

// Set the stream position to the beginning of the file.


//[Link](0, [Link]);

[Link](0, 0);
// Download file.
return File(stream, [Link], $"ContractCompletat
{[Link]} {[Link]}.{[Link]()}");

// [ResponseCache(Duration = 0, Location = [Link],


NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel() { RequestId = [Link]?.Id ??
[Link] });
}
}
}

You might also like