Blame view
sources/RoboforkApp/Services/Robofork15DemoService.cs
2.34 KB
1debe12ff
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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 Robofork15DemoService { private readonly DynamoService _dynamoService; |
de8826297
|
15 16 17 18 19 |
public Robofork15DemoService() { _dynamoService = new DynamoService(); } |
1debe12ff
|
20 |
/// <summary> |
de8826297
|
21 |
/// AddRobofork15Demo will accept a Robofork15Demo object and creates an Item on Amazon DynamoDB |
1debe12ff
|
22 23 |
/// </summary> /// <param name="robofork15Demo"></param> |
de8826297
|
24 |
public void AddRobofork15Demo(Robofork15Demo robofork15Demo) |
1debe12ff
|
25 |
{ |
de8826297
|
26 27 28 |
_dynamoService.Store(robofork15Demo); } |
1debe12ff
|
29 |
/// <summary> |
de8826297
|
30 |
/// ModifyRobofork15Demo tries to load an existing Robofork15Demo, modifies and saves it back. If the Item doesn’t exist, it raises an exception |
1debe12ff
|
31 32 |
/// </summary> /// <param name="robofork15Demo"></param> |
de8826297
|
33 |
public void ModifyRobofork15Demo(Robofork15Demo robofork15Demo) |
1debe12ff
|
34 |
{ |
de8826297
|
35 36 37 |
_dynamoService.UpdateItem(robofork15Demo); } |
1debe12ff
|
38 |
/// <summary> |
de8826297
|
39 40 |
/// GetALllRobofork15Demos will perform a Table Scan operation to return all the Robofork15Demos /// </summary> |
1debe12ff
|
41 |
/// <returns></returns> |
de8826297
|
42 |
public IEnumerable<Robofork15Demo> GetAllRobofork15Demos() |
1debe12ff
|
43 |
{ |
de8826297
|
44 |
return _dynamoService.GetAll<Robofork15Demo>(); |
1debe12ff
|
45 46 47 48 49 50 51 |
} /// <summary> /// SearchRobofork15Demos will search all data Robofork15Demos with id /// </summary> /// <param name="forkId">Fork Id</param> /// <returns></returns> |
de8826297
|
52 |
public IEnumerable<Robofork15Demo> SearchRobofork15Demos(int forkId) |
1debe12ff
|
53 54 55 |
{ IEnumerable<Robofork15Demo> filteredRobofork15Demos = _dynamoService.DbContext.Query<Robofork15Demo>(forkId, QueryOperator.Equal); |
de8826297
|
56 57 58 |
return filteredRobofork15Demos; } |
1debe12ff
|
59 |
/// <summary> |
de8826297
|
60 |
/// Delete Robofork15Demo will remove an item from DynamoDb |
1debe12ff
|
61 62 |
/// </summary> /// <param name="robofork15Demo"></param> |
de8826297
|
63 |
public void DeleteRobofork15Demo(Robofork15Demo robofork15Demo) |
1debe12ff
|
64 |
{ |
de8826297
|
65 |
_dynamoService.DeleteItem(robofork15Demo); |
1debe12ff
|
66 67 68 |
} } } |