Skip to content

Instantly share code, notes, and snippets.

@jglozano
Last active November 16, 2017 03:11
Show Gist options
  • Save jglozano/6321ff153bdfdc3b13aeb3a98dd4c6bc to your computer and use it in GitHub Desktop.
Save jglozano/6321ff153bdfdc3b13aeb3a98dd4c6bc to your computer and use it in GitHub Desktop.
.NET Development YTT Demo - HomeController code
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using System.IO;
using Northwind.Data;
namespace Northwind.Web.Controllers
{
public class HomeController : Controller
{
private readonly IHostingEnvironment hostingEnvironment;
public HomeController(IHostingEnvironment env)
{
hostingEnvironment = env;
}
public IActionResult Index()
{
// Add to the service
var path = hostingEnvironment.ContentRootPath;
var folderPath = Path.Combine(path, "Database");
var filePath = Path.Combine(folderPath, "northwind.xml");
var data = NorthwindDb.GetData(filePath);
return View("index", data);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment