84 lines
2.2 KiB
C#
84 lines
2.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using LeafWeb.Core.Entities;
|
|
using LeafWeb.Core.Utility;
|
|
using LeafWeb.WebCms.Models;
|
|
using LeafWeb.WebCms.Utility;
|
|
using Umbraco.Web.Mvc;
|
|
|
|
namespace LeafWeb.WebCms.Controllers
|
|
{
|
|
public class ResultsController : BaseController
|
|
{
|
|
[MemberAuthorize(AllowGroup = "Authenticated")]
|
|
public ActionResult Index(LeafDataQuery query)
|
|
{
|
|
var resultItems =
|
|
DataService.GetLeafInputsOrdered();
|
|
|
|
resultItems = QueryFilter.Search(resultItems, query);
|
|
|
|
var searchViewModel = new SearchViewModel
|
|
{
|
|
Items = resultItems,
|
|
Q = query
|
|
};
|
|
|
|
return View(searchViewModel);
|
|
}
|
|
|
|
|
|
[MemberAuthorize(AllowGroup = "Authenticated")]
|
|
[HttpPost]
|
|
public ActionResult Search(LeafDataQuery query)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return CurrentUmbracoPage();
|
|
}
|
|
|
|
return RedirectToCurrentUmbracoPage(query.GetNameValueCollection());
|
|
}
|
|
|
|
public ActionResult Details(int id)
|
|
{
|
|
var leafInput = DataService.GetLeafInput(id);
|
|
|
|
if (leafInput == null)
|
|
{
|
|
SetStatusMessage($"LeafInput '${id}' not found, may have been deleted?");
|
|
RedirectToUmbracoPage(LeafWebPageIds.ManageQueue);
|
|
}
|
|
|
|
var viewModel = new LeafInputDetails_Admin(leafInput);
|
|
return View(viewModel);
|
|
}
|
|
|
|
|
|
public ActionResult Recent()
|
|
{
|
|
var dateThreshold = DateTime.Today.Subtract(TimeSpan.FromDays(90));
|
|
var viewModel =
|
|
from li in DataService.GetLeafInputsOrdered()
|
|
where li.Added >= dateThreshold
|
|
select li;
|
|
return View(viewModel);
|
|
}
|
|
|
|
[ActionLog]
|
|
public ActionResult Download(string token)
|
|
{
|
|
var leafInput = DataService.GetLeafInput(token);
|
|
|
|
if (leafInput == null)
|
|
return View("DownloadNotFound");
|
|
|
|
var zip = leafInput.GetOutputFileZip(LeafOutputFileType.ToUser);
|
|
|
|
var filename = leafInput.Identifier.FilterValidFilename() + ".zip";
|
|
|
|
return new FileContentResult(zip, "application/zip") { FileDownloadName = filename };
|
|
}
|
|
}
|
|
} |