Moves templatequery models into the right folder
This commit is contained in:
15
src/Umbraco.Web/Models/TemplateQuery/ContentTypeModel.cs
Normal file
15
src/Umbraco.Web/Models/TemplateQuery/ContentTypeModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class ContentTypeModel
|
||||
{
|
||||
public string Alias { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/Umbraco.Web/Models/TemplateQuery/Operathor.cs
Normal file
14
src/Umbraco.Web/Models/TemplateQuery/Operathor.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public enum Operathor
|
||||
{
|
||||
Equals = 1,
|
||||
NotEquals = 2,
|
||||
Contains = 3,
|
||||
NotContains = 4,
|
||||
LessThan = 5,
|
||||
LessThanEqualTo = 6,
|
||||
GreaterThan = 7,
|
||||
GreaterThanEqualTo = 8
|
||||
}
|
||||
}
|
||||
25
src/Umbraco.Web/Models/TemplateQuery/OperathorTerm.cs
Normal file
25
src/Umbraco.Web/Models/TemplateQuery/OperathorTerm.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class OperathorTerm
|
||||
{
|
||||
public OperathorTerm()
|
||||
{
|
||||
Name = "is";
|
||||
Operathor = Operathor.Equals;
|
||||
AppliesTo = new [] { "string" };
|
||||
}
|
||||
|
||||
public OperathorTerm(string name, Operathor operathor, IEnumerable<string> appliesTo)
|
||||
{
|
||||
Name = name;
|
||||
Operathor = operathor;
|
||||
AppliesTo = appliesTo;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public Operathor Operathor { get; set; }
|
||||
public IEnumerable<string> AppliesTo { get; set; }
|
||||
}
|
||||
}
|
||||
17
src/Umbraco.Web/Models/TemplateQuery/PropertyModel.cs
Normal file
17
src/Umbraco.Web/Models/TemplateQuery/PropertyModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class PropertyModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Alias { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
60
src/Umbraco.Web/Models/TemplateQuery/QueryCondition.cs
Normal file
60
src/Umbraco.Web/Models/TemplateQuery/QueryCondition.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class QueryCondition
|
||||
{
|
||||
|
||||
public PropertyModel Property { get; set; }
|
||||
public OperathorTerm Term { get; set; }
|
||||
public string ConstraintValue { get; set; }
|
||||
}
|
||||
|
||||
|
||||
internal static class QueryConditionExtensions
|
||||
{
|
||||
private static string MakeBinaryOperation(this QueryCondition condition, string operand, int token)
|
||||
{
|
||||
return string.Format("{0}{1}@{2}", condition.Property.Name, operand, token);
|
||||
}
|
||||
|
||||
|
||||
public static string BuildCondition(this QueryCondition condition, int token)
|
||||
{
|
||||
var operand = string.Empty;
|
||||
var value = string.Empty;
|
||||
|
||||
switch (condition.Term.Operathor)
|
||||
{
|
||||
case Operathor.Equals:
|
||||
operand = " == ";
|
||||
break;
|
||||
case Operathor.NotEquals:
|
||||
operand = " != ";
|
||||
break;
|
||||
case Operathor.GreaterThan:
|
||||
operand = " > ";
|
||||
break;
|
||||
case Operathor.GreaterThanEqualTo:
|
||||
operand = " >= ";
|
||||
break;
|
||||
case Operathor.LessThan:
|
||||
operand = " < ";
|
||||
break;
|
||||
case Operathor.LessThanEqualTo:
|
||||
operand = " <= ";
|
||||
break;
|
||||
case Operathor.Contains:
|
||||
value = string.Format("{0}.Contains(@{1})", condition.Property.Name, token);
|
||||
break;
|
||||
case Operathor.NotContains:
|
||||
value = string.Format("!{0}.Contains(@{1})", condition.Property.Name, token);
|
||||
break;
|
||||
default :
|
||||
operand = " == ";
|
||||
break;
|
||||
}
|
||||
|
||||
return string.IsNullOrEmpty(value) ? condition.MakeBinaryOperation(operand, token) : value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
src/Umbraco.Web/Models/TemplateQuery/QueryModel.cs
Normal file
13
src/Umbraco.Web/Models/TemplateQuery/QueryModel.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class QueryModel
|
||||
{
|
||||
public ContentTypeModel ContentType { get; set; }
|
||||
public SourceModel Source { get; set; }
|
||||
public IEnumerable<QueryCondition> Filters { get; set; }
|
||||
public SortExpression Sort { get; set; }
|
||||
public int Take { get; set; }
|
||||
}
|
||||
}
|
||||
15
src/Umbraco.Web/Models/TemplateQuery/QueryResultModel.cs
Normal file
15
src/Umbraco.Web/Models/TemplateQuery/QueryResultModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
|
||||
public class QueryResultModel
|
||||
{
|
||||
|
||||
public string QueryExpression { get; set; }
|
||||
public IEnumerable<TemplateQueryResult> SampleResults { get; set; }
|
||||
public int ResultCount { get; set; }
|
||||
public double ExecutionTime { get; set; }
|
||||
public int Take { get; set; }
|
||||
}
|
||||
}
|
||||
9
src/Umbraco.Web/Models/TemplateQuery/SortExpression.cs
Normal file
9
src/Umbraco.Web/Models/TemplateQuery/SortExpression.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class SortExpression
|
||||
{
|
||||
public PropertyModel Property { get; set; }
|
||||
|
||||
public string Direction { get; set; }
|
||||
}
|
||||
}
|
||||
8
src/Umbraco.Web/Models/TemplateQuery/SourceModel.cs
Normal file
8
src/Umbraco.Web/Models/TemplateQuery/SourceModel.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class SourceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Umbraco.Web.Models.TemplateQuery
|
||||
{
|
||||
public class TemplateQueryResult
|
||||
{
|
||||
public string Icon { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user