public async Task <User> GetAsync(string partitionKey, string rowKey) { try { var table = await _azureStorageHelper.EnsureTableExistenceAndGetReferenceAsync(partitionKey); User user = null; if (partitionKey == "Administrator") { user = await RetrieveEntityAsync <Administrator>(table, partitionKey, rowKey); } else if (partitionKey == "Student") { user = await RetrieveEntityAsync <Student>(table, partitionKey, rowKey); } else if (partitionKey == "Parent") { user = await RetrieveEntityAsync <Parent>(table, partitionKey, rowKey); } else if (partitionKey == "Teacher") { user = await RetrieveEntityAsync <Teacher>(table, partitionKey, rowKey); } else { throw new TableException("Pobieranie obiektu z bazy danych nie powiodło się. Niepoprawny typ użytkownika."); } return(user); } catch (Exception exception) { throw new TableException("Pobieranie obiektu z bazy danych nie powiodło się.", exception); } }
public async Task <StudentsClass> GetAsync(string partitionKey, string rowKey) { try { var table = await _azureStorageHelper.EnsureTableExistenceAndGetReferenceAsync("StudentsClass"); var retrieveOperation = TableOperation.Retrieve <StudentsClass>(partitionKey, rowKey); var tableResult = await table.ExecuteAsync(retrieveOperation); return(tableResult.Result as StudentsClass); } catch (Exception exception) { throw new TableException("Pobieranie obiektu z bazy danych nie powiodło się.", exception); } }