Skip to content

Commit

Permalink
DummyEntry.json added
Browse files Browse the repository at this point in the history
  • Loading branch information
selcukyavuz committed Sep 24, 2021
1 parent 49359b3 commit 2f7b24b
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


bin/
obj/
obj/
.vs/
152 changes: 152 additions & 0 deletions Data/DummyEntry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
[
{
"id": "affbc12a-4f1b-435d-9937-dda28860a260",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "insert",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Text",
"value": "Jhon Smith"
},
"oldEntity": null,
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632402850",
"timeStamp": "2021-09-23T13:14:10+00:00"
},
{
"id": "5fd5ce0e-4277-4f47-870f-9bd696ce150d",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "update",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Text",
"value": "Jhon X Smith"
},
"oldEntity": {
"id": "123",
"name": "Customer",
"dataType": "Text",
"value": "Jhon Smith"
},
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632402883",
"timeStamp": "2021-09-23T13:14:43+00:00"
},
{
"id": "7e4d31b6-ebaa-4348-9eca-ad39c3d36665",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "delete",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Text",
"value": "Jhon X Smith"
},
"oldEntity": null,
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632402908",
"timeStamp": "2021-09-23T13:15:08+00:00"
},
{
"id": "db9344e2-099d-4dfe-875c-f4963ea3143b",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "insert",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Json",
"value": "{ \"id\" : \"123\", \"name\" : \"jhon\" }"
},
"oldEntity": null,
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632403090",
"timeStamp": "2021-09-23T13:18:10+00:00"
},
{
"id": "0709395f-04ac-43ea-8716-2271514b8a61",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "update",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Json",
"value": "{ \"id\" : \"123\", \"name\" : \"jhon\" }"
},
"oldEntity": {
"id": "123",
"name": "Customer",
"dataType": "Json",
"value": "{ \"id\" : \"123\", \"name\" : \"json X\" }"
},
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632403129",
"timeStamp": "2021-09-23T13:18:49+00:00"
},
{
"id": "6a217902-0853-42b7-b822-e4011da902d5",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "delete",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Json",
"value": "{ \"id\" : \"123\", \"name\" : \"jhon\" }"
},
"oldEntity": null,
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632403154",
"timeStamp": "2021-09-23T13:19:14+00:00"
},
{
"id": "6891b93b-53cc-4827-93ae-01f9008c801b",
"parentId": null,
"partitionKey": "Entry",
"who": "joe",
"when": "2021-09-24T10:48:12.999817+00:00",
"what": "insert",
"currentEntity": {
"id": "123",
"name": "Customer",
"dataType": "Json",
"value": "{ \"id\" : \"123\", \"name\" : \"jhon\" }"
},
"oldEntity": null,
"ip": "127.0.0.1",
"computerName": "HP-127",
"ticketNumber": "10001123",
"_ts": "1632431295",
"timeStamp": "2021-09-23T21:08:15+00:00"
}
]
22 changes: 19 additions & 3 deletions Data/EntryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,39 @@
using System.Net;
using Newtonsoft.Json;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting;

namespace wwdt_ui.Data
{
public class EntryService
{
private IConfigurationRoot _config;
private IWebHostEnvironment _env;

public EntryService(IConfiguration config)
public EntryService(IConfiguration config, IWebHostEnvironment env)
{
_config = (IConfigurationRoot)config;
_env = env;
}

public Task<Entry[]> GetEntryAsync()
{
var apiUrl = _config.GetValue<string>("ApiUrl");
var json = new WebClient().DownloadString(apiUrl);

string json = string.Empty;

if (_env.IsDevelopment())
{
string dataFolder = System.IO.Path.Combine(_env.ContentRootPath, "Data");
string dummyFile = System.IO.Path.Combine(dataFolder, "DummyEntry.json");
json = System.IO.File.ReadAllText(dummyFile);
}
else
{
json = new WebClient().DownloadString(apiUrl);
}


List<Entry> entryList = JsonConvert.DeserializeObject<List<Entry>>(json);

return Task.FromResult(entryList.ToArray());
Expand Down
6 changes: 0 additions & 6 deletions wwdt-ui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,4 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<Content Remove="wwwroot\healtcheck.html" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\healtcheck.html" />
</ItemGroup>
</Project>

0 comments on commit 2f7b24b

Please sign in to comment.