Skip to content

Commit c01556b

Browse files
Migrated Models
1 parent f613ce8 commit c01556b

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace jQueryDatatableServerSideNetCore.Models.AuxiliaryModels
5+
{
6+
///This view model class has been referred from example created by Marien Monnier at Soft.it. All credits to Marien for this class
7+
8+
/// <summary>
9+
/// A full result, as understood by jQuery DataTables.
10+
/// </summary>
11+
/// <typeparam name="T">The data type of each row.</typeparam>
12+
public class DtResult<T>
13+
{
14+
/// <summary>
15+
/// The draw counter that this object is a response to - from the draw parameter sent as part of the data request.
16+
/// Note that it is strongly recommended for security reasons that you cast this parameter to an integer, rather than simply echoing back to the client what it sent in the draw parameter, in order to prevent Cross Site Scripting (XSS) attacks.
17+
/// </summary>
18+
[JsonProperty("draw")]
19+
public int Draw { get; set; }
20+
21+
/// <summary>
22+
/// Total records, before filtering (i.e. the total number of records in the database)
23+
/// </summary>
24+
[JsonProperty("recordsTotal")]
25+
public int RecordsTotal { get; set; }
26+
27+
/// <summary>
28+
/// Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).
29+
/// </summary>
30+
[JsonProperty("recordsFiltered")]
31+
public int RecordsFiltered { get; set; }
32+
33+
/// <summary>
34+
/// The data to be displayed in the table.
35+
/// This is an array of data source objects, one for each row, which will be used by DataTables.
36+
/// Note that this parameter's name can be changed using the ajaxDT option's dataSrc property.
37+
/// </summary>
38+
[JsonProperty("data")]
39+
public IEnumerable<T> Data { get; set; }
40+
41+
public string PartialView { get; set; }
42+
}
43+
44+
/// <summary>
45+
/// The additional columns that you can send to jQuery DataTables for automatic processing.
46+
/// </summary>
47+
public abstract class DtRow
48+
{
49+
/// <summary>
50+
/// Set the ID property of the dt-tag tr node to this value
51+
/// </summary>
52+
[JsonProperty("DT_RowId")]
53+
public virtual string DtRowId => null;
54+
55+
/// <summary>
56+
/// Add this class to the dt-tag tr node
57+
/// </summary>
58+
[JsonProperty("DT_RowClass")]
59+
public virtual string DtRowClass => null;
60+
61+
/// <summary>
62+
/// Add this data property to the row's dt-tag tr node allowing abstract data to be added to the node, using the HTML5 data-* attributes.
63+
/// This uses the jQuery data() method to set the data, which can also then be used for later retrieval (for example on a click event).
64+
/// </summary>
65+
[JsonProperty("DT_RowData")]
66+
public virtual object DtRowData => null;
67+
}
68+
69+
/// <summary>
70+
/// The parameters sent by jQuery DataTables in AJAX queries.
71+
/// </summary>
72+
public class DtParameters
73+
{
74+
/// <summary>
75+
/// Draw counter.
76+
/// This is used by DataTables to ensure that the Ajax returns from server-side processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and thus can return out of sequence).
77+
/// This is used as part of the draw return parameter (see below).
78+
/// </summary>
79+
public int Draw { get; set; }
80+
81+
/// <summary>
82+
/// An array defining all columns in the table.
83+
/// </summary>
84+
public DtColumn[] Columns { get; set; }
85+
86+
/// <summary>
87+
/// An array defining how many columns are being ordering upon - i.e. if the array length is 1, then a single column sort is being performed, otherwise a multi-column sort is being performed.
88+
/// </summary>
89+
public DtOrder[] Order { get; set; }
90+
91+
/// <summary>
92+
/// Paging first record indicator.
93+
/// This is the start point in the current data set (0 index based - i.e. 0 is the first record).
94+
/// </summary>
95+
public int Start { get; set; }
96+
97+
/// <summary>
98+
/// Number of records that the table can display in the current draw.
99+
/// It is expected that the number of records returned will be equal to this number, unless the server has fewer records to return.
100+
/// Note that this can be -1 to indicate that all records should be returned (although that negates any benefits of server-side processing!)
101+
/// </summary>
102+
public int Length { get; set; }
103+
104+
/// <summary>
105+
/// Global search value. To be applied to all columns which have searchable as true.
106+
/// </summary>
107+
public DtSearch Search { get; set; }
108+
109+
/// <summary>
110+
/// Custom column that is used to further sort on the first Order column.
111+
/// </summary>
112+
public string SortOrder => Columns != null && Order != null && Order.Length > 0
113+
? (Columns[Order[0].Column].Data +
114+
(Order[0].Dir == DtOrderDir.Desc ? " " + Order[0].Dir : string.Empty))
115+
: null;
116+
117+
/// <summary>
118+
/// For Posting Additional Parameters to Server
119+
/// </summary>
120+
public IEnumerable<string> AdditionalValues { get; set; }
121+
122+
}
123+
124+
/// <summary>
125+
/// A jQuery DataTables column.
126+
/// </summary>
127+
public class DtColumn
128+
{
129+
/// <summary>
130+
/// Column's data source, as defined by columns.data.
131+
/// </summary>
132+
public string Data { get; set; }
133+
134+
/// <summary>
135+
/// Column's name, as defined by columns.name.
136+
/// </summary>
137+
public string Name { get; set; }
138+
139+
/// <summary>
140+
/// Flag to indicate if this column is searchable (true) or not (false). This is controlled by columns.searchable.
141+
/// </summary>
142+
public bool Searchable { get; set; }
143+
144+
/// <summary>
145+
/// Flag to indicate if this column is orderable (true) or not (false). This is controlled by columns.orderable.
146+
/// </summary>
147+
public bool Orderable { get; set; }
148+
149+
/// <summary>
150+
/// Specific search value.
151+
/// </summary>
152+
public DtSearch Search { get; set; }
153+
}
154+
155+
/// <summary>
156+
/// An order, as sent by jQuery DataTables when doing AJAX queries.
157+
/// </summary>
158+
public class DtOrder
159+
{
160+
/// <summary>
161+
/// Column to which ordering should be applied.
162+
/// This is an index reference to the columns array of information that is also submitted to the server.
163+
/// </summary>
164+
public int Column { get; set; }
165+
166+
/// <summary>
167+
/// Ordering direction for this column.
168+
/// It will be dt-string asc or dt-string desc to indicate ascending ordering or descending ordering, respectively.
169+
/// </summary>
170+
public DtOrderDir Dir { get; set; }
171+
}
172+
173+
/// <summary>
174+
/// Sort orders of jQuery DataTables.
175+
/// </summary>
176+
public enum DtOrderDir
177+
{
178+
Asc,
179+
Desc
180+
}
181+
182+
/// <summary>
183+
/// A search, as sent by jQuery DataTables when doing AJAX queries.
184+
/// </summary>
185+
public class DtSearch
186+
{
187+
/// <summary>
188+
/// Global search value. To be applied to all columns which have searchable as true.
189+
/// </summary>
190+
public string Value { get; set; }
191+
192+
/// <summary>
193+
/// true if the global filter should be treated as a regular expression for advanced searching, false otherwise.
194+
/// Note that normally server-side processing scripts will not perform regular expression searching for performance reasons on large data sets, but it is technically possible and at the discretion of your script.
195+
/// </summary>
196+
public bool Regex { get; set; }
197+
}
198+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace jQueryDatatableServerSideNetCore.Models.DatabaseModels
4+
{
5+
public class TestRegister
6+
{
7+
public int Id { get; set; }
8+
9+
public string Name { get; set; }
10+
11+
public string FirstSurname { get; set; }
12+
13+
public string SecondSurname { get; set; }
14+
15+
public string Street { get; set; }
16+
17+
public string Phone { get; set; }
18+
19+
public string ZipCode { get; set; }
20+
21+
public string Country { get; set; }
22+
23+
public string Notes { get; set; }
24+
25+
public DateTime CreationDate { get; set; }
26+
}
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace jQueryDatatableServerSideNetCore.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}

0 commit comments

Comments
 (0)