|
11 | 11 | <button class="btn btn-primary" @onclick="Read">Read</button> |
12 | 12 | </div> |
13 | 13 | <div class="col-md-3"> |
14 | | - <button class="btn btn-primary" @onclick="Update">Update</button> |
| 14 | + <button class="btn btn-primary" @onclick="UpdateAsync">Update</button> |
15 | 15 | </div> |
16 | 16 | <div class="col-md-3"> |
17 | | - <button class="btn btn-primary" @onclick="Insert">Insert</button> |
| 17 | + <button class="btn btn-primary" @onclick="InsertAsync">Insert</button> |
18 | 18 | </div> |
19 | 19 | <div class="col-md-3"> |
20 | | - <button class="btn btn-primary" @onclick="Delete">Delete</button> |
| 20 | + <button class="btn btn-primary" @onclick="DeleteAsync">Delete</button> |
21 | 21 | </div> |
22 | 22 | </div> |
23 | 23 | </div> |
|
26 | 26 | <div class="row" id="diagram"> |
27 | 27 | <div class="col-md-10"> |
28 | 28 | <div id="diagram-space" class="content-wrapper"> |
29 | | - <SfDiagramComponent ID="diagramControl" @ref="@diagram" Width="100%" Height="690px" ConnectorCreating="@ConnectorCreating" NodeCreating="@NodeCreating"> |
| 29 | + <SfDiagramComponent ID="diagramControl" @ref="@_diagram" Width="100%" Height="690px" ConnectorCreating="@ConnectorCreating" NodeCreating="@NodeCreating"> |
30 | 30 | <DataSourceSettings ID="EmployeeID" ParentID="ReportsTo"> |
31 | 31 | <SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager> |
32 | 32 | </DataSourceSettings> |
|
38 | 38 |
|
39 | 39 | @functions |
40 | 40 | { |
41 | | - private SfDiagramComponent? diagram; |
42 | | - private static List<EmployeeDetails> employeeDetails { get; set; } |
43 | | - private static List<EmployeeDetails> Details { get; set; } = new List<EmployeeDetails>(); |
44 | | - private Layout LayoutValue = new Layout() { }; |
| 41 | + private SfDiagramComponent? _diagram; |
| 42 | + private static List<EmployeeDetails> _employeeDetails { get; set; } |
| 43 | + private static List<EmployeeDetails> _details { get; set; } = new List<EmployeeDetails>(); |
| 44 | + private Layout _layoutValue = new Layout() { }; |
45 | 45 |
|
46 | 46 | private TreeInfo GetLayoutInfo(IDiagramObject obj, TreeInfo options) |
47 | 47 | { |
|
86 | 86 |
|
87 | 87 | protected override void OnInitialized() |
88 | 88 | { |
89 | | - Details = new List<EmployeeDetails>(); |
90 | | - employeeDetails = new List<EmployeeDetails>() { |
| 89 | + _details = new List<EmployeeDetails>(); |
| 90 | + _employeeDetails = new List<EmployeeDetails>() { |
91 | 91 | new EmployeeDetails { EmployeeID = "1", FirstName = "Andrew", Designation = "CEO", Country = "England", ReportsTo = "", Color = "Red" }, |
92 | 92 | new EmployeeDetails { EmployeeID = "2", FirstName = "Nancy", Designation = "Product Manager", Country = "USA", ReportsTo = "1", Color = "Blue" }, |
93 | 93 | new EmployeeDetails { EmployeeID = "3", FirstName = "Janet", Designation = "Product Manager", Country = "USA", ReportsTo = "1", Color = "Blue" }, |
|
116 | 116 | // Performs data Read operation |
117 | 117 | public override object Read(DataManagerRequest dm, string key = null) |
118 | 118 | { |
119 | | - IEnumerable<EmployeeDetails> DataSource = employeeDetails; |
| 119 | + IEnumerable<EmployeeDetails> DataSource = _employeeDetails; |
120 | 120 | if (dm.Search != null && dm.Search.Count > 0) |
121 | 121 | { |
122 | 122 | // Searching |
|
148 | 148 | // Performs Insert operation |
149 | 149 | public override object Insert(DataManager dm, object value, string key) |
150 | 150 | { |
151 | | - employeeDetails.Insert(employeeDetails.Count, value as EmployeeDetails); |
| 151 | + _employeeDetails.Insert(_employeeDetails.Count, value as EmployeeDetails); |
152 | 152 | return value; |
153 | 153 | } |
154 | 154 |
|
155 | 155 | // Performs Remove operation |
156 | 156 | public override object Remove(DataManager dm, object value, string keyField, string key) |
157 | 157 | { |
158 | | - employeeDetails.Remove(employeeDetails.Where(or => or.EmployeeID == value.ToString()).FirstOrDefault()); |
| 158 | + _employeeDetails.Remove(_employeeDetails.Where(or => or.EmployeeID == value.ToString()).FirstOrDefault()); |
159 | 159 | return value; |
160 | 160 | } |
161 | 161 |
|
162 | 162 | // Performs Update operation |
163 | 163 | public override object Update(DataManager dm, object value, string keyField, string key) |
164 | 164 | { |
165 | | - var data = employeeDetails.Where(or => or.EmployeeID == (value as EmployeeDetails).EmployeeID).FirstOrDefault(); |
| 165 | + var data = _employeeDetails.Where(or => or.EmployeeID == (value as EmployeeDetails).EmployeeID).FirstOrDefault(); |
166 | 166 | if (data != null) |
167 | 167 | { |
168 | 168 | data.EmployeeID = (value as EmployeeDetails).EmployeeID; |
|
179 | 179 |
|
180 | 180 | private void Read() |
181 | 181 | { |
182 | | - Details = new List<EmployeeDetails>(); |
183 | | - Details = diagram.ReadDataAsync().Result as List<EmployeeDetails>; |
| 182 | + _details = new List<EmployeeDetails>(); |
| 183 | + _details = _diagram.ReadDataAsync().Result as List<EmployeeDetails>; |
184 | 184 | } |
185 | 185 |
|
186 | | - private async void Update() |
| 186 | + private async void UpdateAsync() |
187 | 187 | { |
188 | 188 | EmployeeDetails employeeDetails = new EmployeeDetails { EmployeeID = "1", FirstName = "AndrewSimonds", Designation = "CEO", Country = "Australia", ReportsTo = "", Color = "Red" }; |
189 | | - await diagram.UpdateDataAsync("EmployeeID", employeeDetails); |
| 189 | + await _diagram.UpdateDataAsync("EmployeeID", employeeDetails); |
190 | 190 | } |
191 | 191 |
|
192 | | - private async void Insert() |
| 192 | + private async void InsertAsync() |
193 | 193 | { |
194 | 194 | EmployeeDetails employeeDetails = new EmployeeDetails() |
195 | 195 | { |
|
200 | 200 | ReportsTo = "6", |
201 | 201 | Color = "Purple" |
202 | 202 | }; |
203 | | - await diagram.InsertDataAsync(employeeDetails); |
| 203 | + await _diagram.InsertDataAsync(employeeDetails); |
204 | 204 |
|
205 | 205 | } |
206 | 206 |
|
207 | | - private async void Delete() |
| 207 | + private async void DeleteAsync() |
208 | 208 | { |
209 | | - await diagram.DeleteDataAsync("EmployeeID", "6"); |
| 209 | + await _diagram.DeleteDataAsync("EmployeeID", "6"); |
210 | 210 | } |
211 | 211 | } |
0 commit comments