Use EntityFramework on machine controller.

This commit is contained in:
2018-08-06 23:24:00 +01:00
parent dc62d1f2f4
commit 26c197f28c
2 changed files with 471 additions and 471 deletions

View File

@@ -28,7 +28,8 @@
// Copyright © 2003-2018 Natalia Portillo // Copyright © 2003-2018 Natalia Portillo
*******************************************************************************/ *******************************************************************************/
using cicm_web.Models; using System.Linq;
using Cicm.Database.Models;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -36,18 +37,20 @@ namespace cicm_web.Controllers
{ {
public class MachineController : Controller public class MachineController : Controller
{ {
readonly cicmContext _context;
readonly IHostingEnvironment hostingEnvironment; readonly IHostingEnvironment hostingEnvironment;
public MachineController(IHostingEnvironment env) public MachineController(IHostingEnvironment env, cicmContext context)
{ {
hostingEnvironment = env; hostingEnvironment = env;
_context = context;
} }
public IActionResult View(int id) public IActionResult View(int id)
{ {
ViewBag.WebRootPath = hostingEnvironment.WebRootPath; ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
return View(Machine.GetItem(id)); return View(_context.Machines.FirstOrDefault(m => m.Id == id));
} }
} }
} }

File diff suppressed because it is too large Load Diff