Skip to content

Commit 7059903

Browse files
committed
Cascading-dropdown-remote-data
1 parent f469a84 commit 7059903

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+53462
-0
lines changed

Cascading-dropdown-remote-data/filter_core/.vs/config/applicationhost.config

Lines changed: 990 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27428.2015
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "filter_core", "filter_core\filter_core.csproj", "{863C6282-A34E-4B20-B959-8393DEDA592F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{863C6282-A34E-4B20-B959-8393DEDA592F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{863C6282-A34E-4B20-B959-8393DEDA592F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{863C6282-A34E-4B20-B959-8393DEDA592F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{863C6282-A34E-4B20-B959-8393DEDA592F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {E25874A3-9C9B-40BD-B381-05866527B182}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Mvc;
7+
using filter_core.Models;
8+
using Syncfusion.EJ2.Base;
9+
10+
namespace TestSample.Controllers
11+
{
12+
13+
public class HomeController : Controller
14+
{
15+
16+
public static List<States> state = new List<States>();
17+
public static List<Country> country= new List<Country>();
18+
public IActionResult Index()
19+
{
20+
var Order = OrdersDetails.GetAllRecords();
21+
ViewBag.DataSource = Order;
22+
23+
return View();
24+
}
25+
26+
27+
public IActionResult StateDataSource([FromBody]ExtendedDataManager dm)
28+
{
29+
30+
var state = States.getStates();
31+
32+
var Data = state.ToList();
33+
int count = state.Count();
34+
35+
36+
List<States> iterateState= new List<States>();
37+
foreach (States st in state) {
38+
if (st.countryId == (Int64)dm.Where[0].value) {
39+
iterateState.Add(st);
40+
}
41+
}
42+
return dm.RequiresCounts ? Json(new { result = Data.Skip(dm.Skip).Take(dm.Take), count = count }) : Json(iterateState.ToList());
43+
}
44+
45+
public IActionResult CountryDataSource([FromBody]ExtendedDataManager dm)
46+
{
47+
48+
var country = Country.getCountries();
49+
var Data = country.ToList();
50+
int count = country.Count();
51+
52+
return dm.RequiresCounts ? Json(new { result = Data.Skip(dm.Skip).Take(dm.Take), count = count }) : Json(Data);
53+
}
54+
55+
public class ExtendedDataManager : DataManagerRequest
56+
{
57+
public IDictionary<string, string> @params;
58+
}
59+
60+
61+
62+
public IActionResult UrlDatasource([FromBody]Data dm)
63+
{
64+
var order = OrdersDetails.GetAllRecords();
65+
var Data = order.ToList();
66+
int count = order.Count();
67+
return dm.requiresCounts ? Json(new { result = Data.Skip(dm.skip).Take(dm.take), count = count }) : Json(Data);
68+
}
69+
70+
public ActionResult Update([FromBody]CRUDModel<OrdersDetails> value)
71+
{
72+
var ord = value.value;
73+
OrdersDetails val = OrdersDetails.GetAllRecords().Where(or => or.OrderID == ord.OrderID).FirstOrDefault();
74+
val.OrderID = ord.OrderID;
75+
val.EmployeeID = ord.EmployeeID;
76+
val.CustomerID = ord.CustomerID;
77+
val.Freight = ord.Freight;
78+
val.OrderDate = ord.OrderDate;
79+
val.ShipCity = ord.ShipCity;
80+
81+
return Json(value.value);
82+
}
83+
//insert the record
84+
public ActionResult Insert([FromBody]CRUDModel<OrdersDetails> value)
85+
{
86+
87+
OrdersDetails.GetAllRecords().Insert(0, value.value);
88+
return Json(value.value);
89+
}
90+
//Delete the record
91+
public ActionResult CellEditDelete([FromBody]CRUDModel<OrdersDetails> value)
92+
{
93+
OrdersDetails.GetAllRecords().Remove(OrdersDetails.GetAllRecords().Where(or => or.OrderID == int.Parse(value.key.ToString())).FirstOrDefault());
94+
return Json(value);
95+
}
96+
97+
public class Country
98+
{
99+
public Country()
100+
{
101+
102+
}
103+
104+
public Country(int cid, string cname)
105+
{
106+
this.countryId = cid;
107+
this.countryName = cname;
108+
}
109+
public int countryId { get; set; }
110+
public string countryName { get; set; }
111+
public static List<Country> getCountries()
112+
{
113+
if (country.Count == 0)
114+
{
115+
116+
country.Add(new Country(1, "United States"));
117+
country.Add(new Country(2, "Australia"));
118+
}
119+
return country;
120+
}
121+
}
122+
123+
124+
public class States
125+
{
126+
127+
public States() {
128+
129+
}
130+
131+
public States(int cid,int sid, string sname) {
132+
this.stateId= sid;
133+
this.countryId = cid;
134+
this.stateName = sname;
135+
}
136+
public int countryId { get; set; }
137+
public int stateId { get; set; }
138+
public string stateName { get; set; }
139+
public static List<States> getStates()
140+
{
141+
if (state.Count == 0)
142+
{
143+
state.Add(new States(1, 101, "New York"));
144+
state.Add(new States(1, 102, "Virginia"));
145+
state.Add(new States(1, 103, "Washington"));
146+
state.Add(new States(2, 104, "Queensland"));
147+
state.Add(new States(2, 105, "Tasmania"));
148+
state.Add(new States(2, 106, "Victoria"));
149+
}
150+
return state;
151+
}
152+
}
153+
154+
155+
public class Data
156+
{
157+
158+
public bool requiresCounts { get; set; }
159+
public int skip { get; set; }
160+
public int take { get; set; }
161+
public Dictionary<string, object> @params { get; set; }
162+
}
163+
public class CRUDModel<T> where T : class
164+
{
165+
public string action { get; set; }
166+
167+
public string table { get; set; }
168+
169+
public string keyColumn { get; set; }
170+
171+
public object key { get; set; }
172+
173+
public T value { get; set; }
174+
175+
public List<T> added { get; set; }
176+
177+
public List<T> changed { get; set; }
178+
179+
public List<T> deleted { get; set; }
180+
181+
public IDictionary<string, object> @params { get; set; }
182+
}
183+
}
184+
public class OrdersDetails
185+
{
186+
public static List<OrdersDetails> order = new List<OrdersDetails>();
187+
public OrdersDetails()
188+
{
189+
190+
}
191+
public OrdersDetails(int OrderID, string CustomerId, int EmployeeId, double Freight, bool Verified, DateTime OrderDate, string ShipCity, string ShipName, string ShipCountry, DateTime ShippedDate, string ShipAddress)
192+
{
193+
this.OrderID = OrderID;
194+
this.CustomerID = CustomerId;
195+
this.EmployeeID = EmployeeId;
196+
this.Freight = Freight;
197+
this.ShipCity = ShipCity;
198+
this.Verified = Verified;
199+
this.OrderDate = OrderDate;
200+
this.ShipName = ShipName;
201+
this.ShipCountry = ShipCountry;
202+
this.ShippedDate = ShippedDate;
203+
this.ShipAddress = ShipAddress;
204+
}
205+
public static List<OrdersDetails> GetAllRecords()
206+
{
207+
if (order.Count() == 0)
208+
{
209+
int code = 10000;
210+
for (int i = 1; i < 10; i++)
211+
{
212+
order.Add(new OrdersDetails(code + 1, "ALFKI", i + 0, 2.3 * i, false, new DateTime(1991, 05, 15), "Berlin", "Simons bistro", "Denmark", new DateTime(1996, 7, 16), "Kirchgasse 6"));
213+
order.Add(new OrdersDetails(code + 2, "ANATR", i + 2, 3.3 * i, true, new DateTime(1990, 04, 04), "Madrid", "Queen Cozinha", "Brazil", new DateTime(1996, 9, 11), "Avda. Azteca 123"));
214+
order.Add(new OrdersDetails(code + 3, "ANTON", i + 1, 4.3 * i, true, new DateTime(1957, 11, 30), "Cholchester", "Frankenversand", "Germany", new DateTime(1996, 10, 7), "Carrera 52 con Ave. Bolívar #65-98 Llano Largo"));
215+
order.Add(new OrdersDetails(code + 4, "BLONP", i + 3, 5.3 * i, false, new DateTime(1930, 10, 22), "Marseille", "Ernst Handel", "Austria", new DateTime(1996, 12, 30), "Magazinweg 7"));
216+
order.Add(new OrdersDetails(code + 5, "BOLID", i + 4, 6.3 * i, true, new DateTime(1953, 02, 18), "Tsawassen", "Hanari Carnes", "Switzerland", new DateTime(1997, 12, 3), "1029 - 12th Ave. S."));
217+
code += 5;
218+
}
219+
}
220+
return order;
221+
}
222+
223+
public int? OrderID { get; set; }
224+
public string CustomerID { get; set; }
225+
public int? EmployeeID { get; set; }
226+
public double? Freight { get; set; }
227+
public string ShipCity { get; set; }
228+
public bool Verified { get; set; }
229+
public DateTime OrderDate { get; set; }
230+
231+
public string ShipName { get; set; }
232+
233+
public string ShipCountry { get; set; }
234+
235+
public DateTime ShippedDate { get; set; }
236+
public string ShipAddress { get; set; }
237+
}
238+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace filter_core.Models
4+
{
5+
public class ErrorViewModel
6+
{
7+
public string RequestId { get; set; }
8+
9+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
10+
}
11+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace filter_core
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
BuildWebHost(args).Run();
18+
}
19+
20+
public static IWebHost BuildWebHost(string[] args) =>
21+
WebHost.CreateDefaultBuilder(args)
22+
.UseStartup<Startup>()
23+
.Build();
24+
}
25+
}

0 commit comments

Comments
 (0)