@@ -14,31 +14,22 @@ namespace RemoteSave.Controllers
1414{
1515 public class HomeController : Controller
1616 {
17-
18-
1917 public ActionResult Index ( )
2018 {
21-
22-
23-
2419 return View ( ) ;
2520 }
2621 public ActionResult UrlDatasource ( DataManagerRequest dm )
2722 {
2823 if ( TreeData . tree . Count == 0 )
2924 TreeData . GetTree ( ) ;
3025 IEnumerable DataSource = TreeData . tree ;
31- IEnumerable src = null ;
32- IEnumerable dest = null ;
33- IEnumerable aggregate = null ;
3426
3527 DataOperations operation = new DataOperations ( ) ;
3628 if ( dm . Where != null && dm . Where . Count > 0 )
3729 {
3830 DataSource = operation . PerformFiltering ( DataSource , dm . Where , "and" ) ;
3931 }
4032 List < string > str = new List < string > ( ) ;
41-
4233
4334 if ( dm . Sorted != null && dm . Sorted . Count > 0 )
4435 {
@@ -53,15 +44,9 @@ public ActionResult UrlDatasource(DataManagerRequest dm)
5344 {
5445 DataSource = operation . PerformTake ( DataSource , dm . Take ) ;
5546 }
56-
57-
58-
59-
60- return dm . RequiresCounts ? Json ( new { result = DataSource , count = count } ) : Json ( DataSource ) ;
47+ return dm . RequiresCounts ? Json ( new { result = DataSource , count = count } ) : Json ( DataSource ) ;
6148 }
6249
63-
64-
6550 public ActionResult Update ( TreeData value )
6651 {
6752 var val = TreeData . tree . Where ( ds => ds . TaskID == value . TaskID ) . FirstOrDefault ( ) ;
@@ -86,7 +71,7 @@ public void Insert(TreeData value, int relationalKey)
8671 }
8772 }
8873 i += FindChildRecords ( relationalKey ) ;
89- TreeData . tree . Insert ( i + 1 , value ) ;
74+ TreeData . tree . Insert ( i + 1 , value ) ;
9075 }
9176 public int FindChildRecords ( int ? id )
9277 {
@@ -101,7 +86,7 @@ public int FindChildRecords(int? id)
10186 }
10287 return count ;
10388 }
104-
89+
10590 public void Delete ( int key )
10691 {
10792 TreeData . tree . Remove ( TreeData . tree . Where ( ds => ds . TaskID == key ) . FirstOrDefault ( ) ) ;
@@ -131,59 +116,56 @@ public class ICRUDModel
131116 }
132117
133118 }
134-
135-
136-
137- public class TreeData
119+ public class TreeData
120+ {
121+ public static List < TreeData > tree = new List < TreeData > ( ) ;
122+ [ System . ComponentModel . DataAnnotations . Key ]
123+ public int TaskID { get ; set ; }
124+ public string TaskName { get ; set ; }
125+ public DateTime StartDate { get ; set ; }
126+ public DateTime EndDate { get ; set ; }
127+ public String Progress { get ; set ; }
128+ public String Priority { get ; set ; }
129+ public int Duration { get ; set ; }
130+ public int ? ParentItem { get ; set ; }
131+ public bool ? isParent { get ; set ; }
132+ public TreeData ( ) { }
133+ public static List < TreeData > GetTree ( )
138134 {
139- public static List < TreeData > tree = new List < TreeData > ( ) ;
140- [ System . ComponentModel . DataAnnotations . Key ]
141- public int TaskID { get ; set ; }
142- public string TaskName { get ; set ; }
143- public DateTime StartDate { get ; set ; }
144- public DateTime EndDate { get ; set ; }
145- public String Progress { get ; set ; }
146- public String Priority { get ; set ; }
147- public int Duration { get ; set ; }
148- public int ? ParentItem { get ; set ; }
149- public bool ? isParent { get ; set ; }
150- public TreeData ( ) { }
151- public static List < TreeData > GetTree ( )
135+ if ( tree . Count == 0 )
152136 {
153- if ( tree . Count == 0 )
154- {
155- int root = - 1 ;
137+ int root = - 1 ;
156138 for ( var t = 1 ; t <= 5 ; t ++ )
157139 {
158140 Random ran = new Random ( ) ;
159- string math = ( ran . Next ( ) % 3 ) == 0 ? "High" : ( ran . Next ( ) % 2 ) == 0 ? "Release Breaker" : "Critical" ;
160- string progr = ( ran . Next ( ) % 3 ) == 0 ? "Started" : ( ran . Next ( ) % 2 ) == 0 ? "Open" : "In Progress" ;
161- root ++ ;
162- int rootItem = tree . Count + root + 1 ;
163- tree . Add ( new TreeData ( ) { TaskID = rootItem , TaskName = "Parent Task " + rootItem . ToString ( ) , StartDate = new DateTime ( 1992 , 06 , 07 ) , EndDate = new DateTime ( 1994 , 08 , 25 ) , isParent = true , ParentItem = null , Progress = progr , Priority = math , Duration = ( ran . Next ( 1 , 50 ) * 5 ) } ) ;
164- int parent = tree . Count ;
165- for ( var c = 0 ; c < 3 ; c ++ )
166- {
167- root ++ ;
168- string val = ( ( parent + c + 1 ) % 3 == 0 ) ? "Low" : "Critical" ;
169- int parn = parent + c + 1 ;
170- progr = ( ran . Next ( ) % 3 ) == 0 ? "In Progress" : ( ran . Next ( ) % 2 ) == 0 ? "Open" : "Validated" ;
171- int iD = tree . Count + root + 1 ;
172- tree . Add ( new TreeData ( ) { TaskID = iD , TaskName = "Child Task " + iD . ToString ( ) , StartDate = new DateTime ( 1992 , 06 , 07 ) , EndDate = new DateTime ( 1994 , 08 , 25 ) , isParent = false , ParentItem = rootItem , Progress = progr , Priority = val , Duration = ran . Next ( 1 , 50 ) } ) ;
173- if ( ( ( ( parent + c + 1 ) % 2 ) == 0 ) )
141+ string math = ( ran . Next ( ) % 3 ) == 0 ? "High" : ( ran . Next ( ) % 2 ) == 0 ? "Release Breaker" : "Critical" ;
142+ string progr = ( ran . Next ( ) % 3 ) == 0 ? "Started" : ( ran . Next ( ) % 2 ) == 0 ? "Open" : "In Progress" ;
143+ root ++ ;
144+ int rootItem = tree . Count + root + 1 ;
145+ tree . Add ( new TreeData ( ) { TaskID = rootItem , TaskName = "Parent Task " + rootItem . ToString ( ) , StartDate = new DateTime ( 1992 , 06 , 07 ) , EndDate = new DateTime ( 1994 , 08 , 25 ) , isParent = true , ParentItem = null , Progress = progr , Priority = math , Duration = ( ran . Next ( 1 , 50 ) * 5 ) } ) ;
146+ int parent = tree . Count ;
147+ for ( var c = 0 ; c < 3 ; c ++ )
174148 {
175- int immParent = tree . Count ;
176- for ( var s = 0 ; s < 2 ; s ++ )
149+ root ++ ;
150+ string val = ( ( parent + c + 1 ) % 3 == 0 ) ? "Low" : "Critical" ;
151+ int parn = parent + c + 1 ;
152+ progr = ( ran . Next ( ) % 3 ) == 0 ? "In Progress" : ( ran . Next ( ) % 2 ) == 0 ? "Open" : "Validated" ;
153+ int iD = tree . Count + root + 1 ;
154+ tree . Add ( new TreeData ( ) { TaskID = iD , TaskName = "Child Task " + iD . ToString ( ) , StartDate = new DateTime ( 1992 , 06 , 07 ) , EndDate = new DateTime ( 1994 , 08 , 25 ) , isParent = false , ParentItem = rootItem , Progress = progr , Priority = val , Duration = ran . Next ( 1 , 50 ) } ) ;
155+ if ( ( ( ( parent + c + 1 ) % 2 ) == 0 ) )
177156 {
178- root ++ ;
179- string Prior = ( immParent % 2 == 0 ) ? "Validated" : "Normal" ;
180- tree . Add ( new TreeData ( ) { TaskID = tree . Count + root + 1 , TaskName = "Sub Task " + ( tree . Count + root + 1 ) . ToString ( ) , StartDate = new DateTime ( 1992 , 06 , 07 ) , EndDate = new DateTime ( 1994 , 08 , 25 ) , isParent = false , ParentItem = iD , Progress = ( immParent % 2 == 0 ) ? "On Progress" : "Closed" , Priority = Prior , Duration = ran . Next ( 1 , 50 ) } ) ;
157+ int immParent = tree . Count ;
158+ for ( var s = 0 ; s < 2 ; s ++ )
159+ {
160+ root ++ ;
161+ string Prior = ( immParent % 2 == 0 ) ? "Validated" : "Normal" ;
162+ tree . Add ( new TreeData ( ) { TaskID = tree . Count + root + 1 , TaskName = "Sub Task " + ( tree . Count + root + 1 ) . ToString ( ) , StartDate = new DateTime ( 1992 , 06 , 07 ) , EndDate = new DateTime ( 1994 , 08 , 25 ) , isParent = false , ParentItem = iD , Progress = ( immParent % 2 == 0 ) ? "On Progress" : "Closed" , Priority = Prior , Duration = ran . Next ( 1 , 50 ) } ) ;
163+ }
181164 }
182165 }
183- }
184- }
185166 }
186- return tree ;
187167 }
168+ return tree ;
188169 }
189170 }
171+ }
0 commit comments