-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
000ac29
commit 8694956
Showing
3 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
using System.Numerics; | ||
|
||
namespace Warehouse.Core.Model; | ||
|
||
public class WarehouseItem | ||
public readonly record struct ItemQuantity(int Value) : IAdditionOperators<ItemQuantity, ItemQuantity, ItemQuantity>, ISubtractionOperators<ItemQuantity, ItemQuantity, ItemQuantity> | ||
{ | ||
public static readonly ItemQuantity Zero = new(0); | ||
public static ItemQuantity operator +(ItemQuantity left, ItemQuantity right) | ||
{ | ||
return new ItemQuantity(left.Value + right.Value); | ||
} | ||
|
||
public static ItemQuantity operator -(ItemQuantity left, ItemQuantity right) | ||
{ | ||
var res = left.Value - right.Value; | ||
return res < 0 ? Zero : new ItemQuantity(res); | ||
} | ||
} | ||
|
||
public sealed record WarehouseItem(ProductId ProductId, ItemQuantity Quantity) | ||
{ | ||
|
||
} |