Skip to content

Commit 626cb56

Browse files
committed
Added documentation to the MarketOrderService.cs
1 parent 179cb88 commit 626cb56

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

Repository/IRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public interface IMarketOrderRepository : IRepository<MarketOrder>
6060
/// Deletes all market orders of the portfolio entry given by an ID
6161
/// </summary>
6262
/// <param name="portfolioEntryId">ID of the entry whose orders should be deleted</param>
63-
/// <returns>A flag indicating whether the orders have been successfully deleted</returns>
63+
/// <returns>Number of orders deleted</returns>
6464
public int DeletePortfolioEntryOrders(int portfolioEntryId);
6565
}
6666

Services/Services/MarketOrderService.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,65 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Runtime.CompilerServices;
43
using Model;
54
using Repository;
65

76
namespace Services
87
{
98
public interface IMarketOrderService
109
{
10+
/// <summary>
11+
/// Creates a new market order and adds it to a repository
12+
/// </summary>
13+
/// <param name="filledPrice">The agreed price per one piece of the traded asset</param>
14+
/// <param name="fee">Fee for trade</param>
15+
/// <param name="size">Size of the trade</param>
16+
/// <param name="date">Date the trade was made</param>
17+
/// <param name="buy">A flag indicating whether the trade is a buy</param>
18+
/// <param name="portfolioEntryId">ID of the portfolio entry the trade belongs to</param>
19+
/// <returns>Created instance of the `MarketOrder` class</returns>
1120
MarketOrder CreateMarketOrder(decimal filledPrice, decimal fee, decimal size,
1221
DateTime date, bool buy, int portfolioEntryId);
1322

23+
/// <summary>
24+
/// Deletes the given order from the repository
25+
/// </summary>
26+
/// <param name="order">Order to be deleted from the repository</param>
27+
/// <returns>A flag indicating whether an order was deleted</returns>
1428
bool DeleteMarketOrder(MarketOrder order);
1529

30+
/// <summary>
31+
/// Updates the given order in the repository. An order with the same ID in the repository is replaced with the one
32+
/// passed.
33+
/// </summary>
34+
/// <param name="order">Updated order</param>
35+
/// <returns>A flag indicating whether an order was updated</returns>
1636
bool UpdateMarketOrder(MarketOrder order);
1737

38+
/// <summary>
39+
/// Loads and returns a market order from a repository
40+
/// </summary>
41+
/// <param name="id">ID of the order to be loaded</param>
42+
/// <returns>Loaded order from the repository or `null` when no order with the given ID was found in the repository</returns>
1843
MarketOrder GetMarketOrder(int id);
1944

45+
/// <summary>
46+
/// Gets all orders of a portfolio entry given by an ID.
47+
/// </summary>
48+
/// <param name="portfolioEntryId">ID of the entry whose orders are to be found</param>
49+
/// <returns>List of all orders belonging to the order specified by the given ID</returns>
2050
List<MarketOrder> GetPortfolioEntryOrders(int portfolioEntryId);
2151

52+
/// <summary>
53+
/// Deletes all orders belonging to the portfolio entry given by it's ID
54+
/// </summary>
55+
/// <param name="portfolioEntryId">ID of the portfolio entry whose orders are to be deleted</param>
56+
/// <returns>Number of deleted orders</returns>
2257
int DeletePortfolioEntryOrders(int portfolioEntryId);
2358
}
2459

2560
public class MarketOrderServiceImpl : IMarketOrderService
2661
{
27-
private IMarketOrderRepository _marketOrderRepository;
62+
private readonly IMarketOrderRepository _marketOrderRepository;
2863

2964
public MarketOrderServiceImpl(IMarketOrderRepository marketOrderRepository)
3065
{
@@ -34,8 +69,13 @@ public MarketOrderServiceImpl(IMarketOrderRepository marketOrderRepository)
3469
public MarketOrder CreateMarketOrder(decimal filledPrice, decimal fee, decimal size, DateTime date, bool buy,
3570
int portfolioEntryId)
3671
{
72+
// create a MarketOrder instance
3773
var order = new MarketOrder(filledPrice, fee, size, date, buy, PortfolioEntryId: portfolioEntryId);
74+
75+
// add it to the repository
3876
var id = _marketOrderRepository.Add(order);
77+
78+
// return the created instance with the ID generated by the repository
3979
return order with {Id = id};
4080
}
4181

0 commit comments

Comments
 (0)