mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Move home controller to EF context.
This commit is contained in:
@@ -29,7 +29,9 @@
|
||||
*******************************************************************************/
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using cicm_web.Models;
|
||||
using Cicm.Database.Models;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -38,16 +40,18 @@ namespace cicm_web.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
readonly IHostingEnvironment hostingEnvironment;
|
||||
readonly cicmContext _context;
|
||||
|
||||
public HomeController(IHostingEnvironment env)
|
||||
public HomeController(IHostingEnvironment env, cicmContext context)
|
||||
{
|
||||
hostingEnvironment = env;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
ViewBag.WebRootPath = hostingEnvironment.WebRootPath;
|
||||
return View(News.GetLastItems());
|
||||
return View(_context.News.OrderByDescending(t => t.Date).Take(10).ToList());
|
||||
}
|
||||
|
||||
public IActionResult About()
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
@using System.IO
|
||||
@model IEnumerable<News>
|
||||
@using News = Cicm.Database.Models.News
|
||||
@model List<Cicm.Database.Models.News>
|
||||
|
||||
<h2>News</h2>
|
||||
|
||||
@@ -46,6 +47,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
News items not yet implemented!
|
||||
@* // TODO
|
||||
@if(news.Image != null && File.Exists(System.IO.Path.Combine(ViewBag.WebRootPath, news.Image + ".jpg")))
|
||||
{
|
||||
<td height="128"
|
||||
@@ -77,6 +80,7 @@
|
||||
@news.SubText
|
||||
</a>
|
||||
</td>
|
||||
*@
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<Version>3.0.99.271</Version>
|
||||
<Version>3.0.99.279</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
Reference in New Issue
Block a user