2021-06-22 00:10:01 +01:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2021-04-08 02:03:17 +01:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-04-11 22:39:26 +01:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-04-25 12:12:50 +01:00
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
using nuget_host.Entities;
|
2021-05-16 14:07:14 +01:00
|
|
|
|
using nuget_host.Data;
|
2021-06-22 00:10:01 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using nuget_host.ViewModels;
|
2021-04-08 02:03:17 +01:00
|
|
|
|
|
|
|
|
|
|
namespace nuget_host.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
|
{
|
2021-04-11 22:39:26 +01:00
|
|
|
|
private readonly ILogger _logger;
|
2021-04-25 12:12:50 +01:00
|
|
|
|
readonly IHostingEnvironment _environment;
|
2021-05-02 15:22:46 +01:00
|
|
|
|
public SmtpSettings _smtpSettings { get; } //set only via Secret Manager
|
2021-04-11 22:39:26 +01:00
|
|
|
|
|
2021-06-22 00:10:01 +01:00
|
|
|
|
private ApplicationDbContext _dbContext;
|
|
|
|
|
|
|
2021-04-25 12:12:50 +01:00
|
|
|
|
public HomeController(
|
|
|
|
|
|
IOptions<SmtpSettings> smtpSettings,
|
2021-05-02 15:22:46 +01:00
|
|
|
|
IHostingEnvironment environment,
|
2021-06-22 00:10:01 +01:00
|
|
|
|
ApplicationDbContext dbContext,
|
2021-05-02 15:22:46 +01:00
|
|
|
|
ILogger<HomeController> logger)
|
2021-04-11 22:39:26 +01:00
|
|
|
|
{
|
|
|
|
|
|
_environment = environment;
|
|
|
|
|
|
_logger = logger;
|
2021-05-02 15:22:46 +01:00
|
|
|
|
_smtpSettings = smtpSettings.Value;
|
2021-06-22 00:10:01 +01:00
|
|
|
|
_dbContext = dbContext;
|
2021-04-11 22:39:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-08 02:03:17 +01:00
|
|
|
|
public IActionResult Index()
|
|
|
|
|
|
{
|
2021-06-22 00:10:01 +01:00
|
|
|
|
return View(new HomeIndexViewModel{
|
|
|
|
|
|
PkgCount = _dbContext.Packages.Count()
|
|
|
|
|
|
});
|
2021-04-08 02:03:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IActionResult About()
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewData["Message"] = "Your application description page.";
|
|
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IActionResult Contact()
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewData["Message"] = "Your contact page.";
|
|
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-25 12:12:50 +01:00
|
|
|
|
public IActionResult Privacy()
|
2021-04-08 02:03:17 +01:00
|
|
|
|
{
|
2021-04-25 12:12:50 +01:00
|
|
|
|
ViewData["Message"] = "Your Privacy page.";
|
2021-04-08 02:03:17 +01:00
|
|
|
|
|
2021-06-21 23:38:05 +01:00
|
|
|
|
return View(ViewData);
|
2021-04-08 02:03:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-23 01:00:57 +01:00
|
|
|
|
public IActionResult Error()
|
|
|
|
|
|
{
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
2021-04-08 02:03:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|