factorisation
This commit is contained in:
@ -13,10 +13,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Models;
|
using Models;
|
||||||
using Yavsc;
|
using Yavsc;
|
||||||
using Yavsc.Helpers;
|
using Yavsc.Helpers;
|
||||||
|
using Yavsc.Models.Workflow;
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
@ -56,28 +58,32 @@ namespace Yavsc.Controllers
|
|||||||
ViewData["HaircutCommandCount"] = DbContext.HairCutQueries.Where(
|
ViewData["HaircutCommandCount"] = DbContext.HairCutQueries.Where(
|
||||||
q=>q.ClientId == uid && q.Status < QueryStatus.Failed
|
q=>q.ClientId == uid && q.Status < QueryStatus.Failed
|
||||||
).Count();
|
).Count();
|
||||||
if (id==null) {
|
var toShow = DbContext.Activities
|
||||||
|
.Include(a=>a.Forms)
|
||||||
|
.Include(a=>a.Parent)
|
||||||
|
.Include(a=>a.Children)
|
||||||
|
.Where(a=>!a.Hidden)
|
||||||
|
.Where(a=>a.ParentCode==id)
|
||||||
|
.OrderByDescending(a=>a.Rate).ToList();
|
||||||
|
|
||||||
|
foreach (var a in toShow) {
|
||||||
|
a.Children=a.Children.Where(c => !c.Hidden).ToList();
|
||||||
|
}
|
||||||
|
return View(toShow);
|
||||||
|
|
||||||
|
//if (id==null) {
|
||||||
// Workaround
|
// Workaround
|
||||||
// NotImplementedException: Remotion.Linq.Clauses.ResultOperators.ConcatResultOperator
|
// NotImplementedException: Remotion.Linq.Clauses.ResultOperators.ConcatResultOperator
|
||||||
//
|
//
|
||||||
// Use Concat()| whatever to do left outer join on ToArray() or ToList(), not on IQueryable
|
// Use Concat()| whatever to do left outer join on ToArray() or ToList(), not on IQueryable
|
||||||
var legacy = DbContext.Activities
|
// var legacy = DbContext.Activities.Include(a=>a.Forms).Include(a=>a.Children).Where(a=> !a.Hidden).Where(a=> a.ParentCode==null).ToArray();
|
||||||
.Include(a=>a.Forms).Include(a=>a.Children)
|
|
||||||
.Where(a=> !a.Hidden)
|
|
||||||
.Where(a=> a.ParentCode==null).ToArray();
|
|
||||||
// OMG
|
// OMG
|
||||||
var hiddenchildren = DbContext.Activities
|
// var hiddenchildren = DbContext.Activities
|
||||||
.Include(a=>a.Forms).Include(a=>a.Children)
|
// .Include(a=>a.Forms).Include(a=>a.Children)
|
||||||
.Where(a=> a.Parent.Hidden && !a.Hidden).ToArray();
|
// .Where(a=> a.Parent.Hidden && !a.Hidden).ToArray();
|
||||||
|
|
||||||
return View(legacy.Concat(hiddenchildren).OrderByDescending(a=>a.Rate));
|
// return View(legacy.Concat(hiddenchildren).OrderByDescending(a=>a.Rate));
|
||||||
}
|
// }
|
||||||
else {
|
|
||||||
return View(DbContext.Activities
|
|
||||||
.Include(a=>a.Forms).Include(a=>a.Children)
|
|
||||||
.Where(a=>!a.Hidden)
|
|
||||||
.Where(a=> a.ParentCode==id).OrderByDescending(a=>a.Rate));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public async Task<IActionResult> About()
|
public async Task<IActionResult> About()
|
||||||
{
|
{
|
||||||
|
@ -46,21 +46,16 @@
|
|||||||
<div class="@cls" style="background-image: url('@act.Photo'); background-repeat: no-repeat; ">
|
<div class="@cls" style="background-image: url('@act.Photo'); background-repeat: no-repeat; ">
|
||||||
|
|
||||||
<div class="carousel-caption-s" >
|
<div class="carousel-caption-s" >
|
||||||
|
<p><em>@act.Name</em><br/>
|
||||||
|
@act.Description </p>
|
||||||
|
|
||||||
@if (act.Children.Count>0) {
|
@if (act.Children.Count>0) {
|
||||||
<p><em>@act.Name</em><br/>
|
|
||||||
@act.Description </p>
|
|
||||||
<a asp-route-id="@act.Code" class="btn btn-default">
|
<a asp-route-id="@act.Code" class="btn btn-default">
|
||||||
@foreach (Activity c in act.Children) {
|
@foreach (Activity c in act.Children) {
|
||||||
@if (!c.Hidden) { @Html.DisplayFor(subact=>c) }
|
@Html.DisplayFor(subact=>c)
|
||||||
}
|
}
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
<p><em>@act.Name</em><br/>
|
|
||||||
@act.Description </p>
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@foreach (var frm in act.Forms) {
|
@foreach (var frm in act.Forms) {
|
||||||
<a class="btn btn-primary" asp-controller="FrontOffice" asp-action="@frm.ActionName" asp-route-id="@act.Code">
|
<a class="btn btn-primary" asp-controller="FrontOffice" asp-action="@frm.ActionName" asp-route-id="@act.Code">
|
||||||
|
Reference in New Issue
Block a user