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