mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Use EntityFramework on machine controller.
This commit is contained in:
@@ -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
Reference in New Issue
Block a user