Fork2PCTableService.cs
2.12 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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();
}
/// <summary>
/// AddFork2PC will accept a Fork2PC object and creates an Item on Amazon DynamoDB
/// </summary>
/// <param name="fork2PC"></param>
public void AddFork2PC(Fork2PC fork2PC)
{
_dynamoService.Store(fork2PC);
}
/// <summary>
/// ModifyFork2PC tries to load an existing Fork2PC, modifies and saves it back. If the Item doesn’t exist, it raises an exception
/// </summary>
/// <param name="fork2PC"></param>
public void ModifyFork2PC(Fork2PC fork2PC)
{
_dynamoService.UpdateItem(fork2PC);
}
/// <summary>
/// GetALllFork2PCs will perform a Table Scan operation to return all the Fork2PCs
/// </summary>
/// <returns></returns>
public IEnumerable<Fork2PC> GetAllFork2PCs()
{
return _dynamoService.GetAll<Fork2PC>();
}
/// <summary>
/// SearchFork2PCs will search all data Fork2PCs with id
/// </summary>
/// <param name="title"></param>
/// <param name="releaseYear"></param>
/// <returns></returns>
public IEnumerable<Fork2PC> SearchFork2PCs(int forkId)
{
IEnumerable<Fork2PC> filteredFork2PCs = _dynamoService.DbContext.Query<Fork2PC>(forkId, QueryOperator.Equal);
return filteredFork2PCs;
}
/// <summary>
/// Delete Fork2PC will remove an item from DynamoDb
/// </summary>
/// <param name="fork2PC"></param>
public void DeleteFork2PC(Fork2PC fork2PC)
{
_dynamoService.DeleteItem(fork2PC);
}
}
}