using System; using System.Collections.Generic; using Amazon.DynamoDBv2; using Amazon.DynamoDBv2.DocumentModel; using Amazon.DynamoDBv2.Model; using RoboforkApp.AWS.DynamoDb; using RoboforkApp.Entities; namespace RoboforkApp.Services { public class Fork2PCTableService { private readonly DynamoService _dynamoService; public Fork2PCTableService() { _dynamoService = new DynamoService(); } /// /// AddFork2PC will accept a Fork2PC object and creates an Item on Amazon DynamoDB /// /// public void AddFork2PC(Fork2PC fork2PC) { _dynamoService.Store(fork2PC); } /// /// ModifyFork2PC tries to load an existing Fork2PC, modifies and saves it back. If the Item doesn’t exist, it raises an exception /// /// public void ModifyFork2PC(Fork2PC fork2PC) { _dynamoService.UpdateItem(fork2PC); } /// /// GetALllFork2PCs will perform a Table Scan operation to return all the Fork2PCs /// /// public IEnumerable GetAllFork2PCs() { return _dynamoService.GetAll(); } /// /// SearchFork2PCs will search all data Fork2PCs with id /// /// /// /// public IEnumerable SearchFork2PCs(int forkId) { IEnumerable filteredFork2PCs = _dynamoService.DbContext.Query(forkId, QueryOperator.Equal); return filteredFork2PCs; } /// /// Delete Fork2PC will remove an item from DynamoDb /// /// public void DeleteFork2PC(Fork2PC fork2PC) { _dynamoService.DeleteItem(fork2PC); } } }