-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuery.cs
More file actions
55 lines (49 loc) · 1.75 KB
/
Copy pathQuery.cs
File metadata and controls
55 lines (49 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using StorageAccountData.Entities;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text.Json;
namespace StorageAccountData
{
public class Query
{
private readonly RequestSender requestSender;
//account - Settings -> Access Key -> Storage Account Name
//key - Settings -> Access Key -> Key1 lub Key2 (bez znaczenia ktory)
//table - nazwa tabeli, na ktorej beda dokonywane zmiany
public Query(string account, string sharedKey, string table)
{
requestSender = new RequestSender(account, sharedKey, table);
}
public string GetAll()
{
try
{
//w konstruktorze przekazujemy metode zapytania oraz dwie wartosci null, poniewaz nic nie tworzymy
//ani niczego nie wyszukujemy
HttpWebRequest request = requestSender.SendRequest("GET", null, null);
IEnumerable<UpdatedEntity> entity = requestSender.GetResponseQueryForAll(request);
//zwracanie jsona z otrzymanego obiektu
return JsonSerializer.Serialize(entity);
}
catch (Exception ex)
{
return ex.Message;
}
}
public string GetByKeys(StorageEntity searchedEntity)
{
try
{
HttpWebRequest request = requestSender.SendRequest("GET", null, searchedEntity);
UpdatedEntity entity = requestSender.GetResponseQuery(request);
//zwracanie jsona z otrzymanego obiektu
return JsonSerializer.Serialize(entity);
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}