csharp/3CORESec/Trapdoor/Storage.cs

Storage.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DataModel;

namespace Trapdoor
{
    [DynamoDBTable("TRAPDOOR_LOG")]
    public clast SessionLog
    {
        [DynamoDBHashKey] public string Id { get; set; }
        [DynamoDBProperty] public byte[] Data { get; set; }
    }

    public clast Storage : DynamoDBContext
    {


        public Storage(IAmazonDynamoDB client) : base(client)
        {
        }

        public async Task GetByHash(string hash)
        {
            try
            {
                var res = await QueryAsync(hash).GetRemainingAsync();
                return res;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return null;
            }
        }

        public async Task Get(string hash, string range)
        {
            try
            {
                var res = await LoadAsync(hash, range);
                return res;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }

        public async Task Store(T dto)
        {
            try
            {
                await SaveAsync(dto);
                return dto;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
    }
}