Search for both LeafInput and LeafInputData

This commit is contained in:
2023-02-02 09:35:22 -05:00
parent 8e16510ad9
commit 680f139aa5
24 changed files with 808 additions and 281 deletions
+45 -14
View File
@@ -3,6 +3,7 @@ using System.Linq;
using System.Web.Mvc;
using LeafWeb.WebCms.Models;
using LeafWeb.WebCms.Utility;
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
using Umbraco.Web.Mvc;
namespace LeafWeb.WebCms.Controllers
@@ -12,22 +13,52 @@ namespace LeafWeb.WebCms.Controllers
[MemberAuthorize(AllowGroup = "Authenticated")]
public ActionResult Index(LeafDataQuery model)
{
if (!model.HasParameters && !TempData.ContainsKey("Posted"))
model.usr = "on";
var resultItems =
DataService.GetLeafInputsOrdered();
resultItems =
QueryFilter.Search(resultItems, model, Members.GetCurrentLoginStatus()?.Email);
var searchViewModel = new SearchViewModel
// if there are no search parameters, show an empty search page
if (!model.HasParameters)
{
Items = resultItems,
Q = model
};
// Default to "only my data"
if (!TempData.ContainsKey("Posted"))
model.usr = "on";
return View(searchViewModel);
model.dsp = LeafDataQuery.LeafInputDataSearchParam;
model.compl = "1";
return View("Index", new SearchLeafInputViewModel
{
Q = model
});
}
var currentUserEmail = Members.GetCurrentLoginStatus()?.Email;
if (model.ShowLeafInputData)
{
var resultItems =
DataService.GetLeafInputData();
resultItems =
QueryFilter.Search(resultItems, model, currentUserEmail);
return View("LeafInputData", new SearchLeafInputDataViewModel
{
Results = resultItems,
Q = model
});
}
else
{
var resultItems =
DataService.GetLeafInputsOrdered();
resultItems =
QueryFilter.Search(resultItems, model, currentUserEmail);
return View("LeafInput", new SearchLeafInputViewModel
{
Results = resultItems,
Q = model
});
}
}
[MemberAuthorize(AllowGroup = "Authenticated")]