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
be8a917
commit b607083
Showing
5 changed files
with
99 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Restbucks.Service.Domain | ||
{ | ||
public class Order | ||
{ | ||
|
||
protected virtual List<Item> ItemsCollection { get; set; } | ||
public virtual IEnumerable<Item> Items | ||
{ | ||
get { return ItemsCollection; } | ||
} | ||
|
||
public virtual Location Location { get; protected set; } | ||
|
||
public virtual decimal Total { get; protected set; } | ||
|
||
public virtual OrderStatus Status { get; protected set; } | ||
|
||
protected Order() | ||
{ | ||
} | ||
|
||
protected Order(Location location, IEnumerable<Item> items) | ||
{ | ||
Location = location; | ||
ItemsCollection = new List<Item>(items); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Restbucks.Service.Domain; | ||
using Restbucks.Service.Representations; | ||
|
||
namespace Restbucks.Service.Mappers | ||
{ | ||
public class ItemRepresentationMapper | ||
{ | ||
public ItemRepresentation GetRepresentation(Item item) | ||
{ | ||
return new ItemRepresentation | ||
{ | ||
Drink = item.Drink, | ||
Milk = item.Milk, | ||
Size = item.Size | ||
}; | ||
} | ||
|
||
public Item GetDomainObject(ItemRepresentation itemRepresentation) | ||
{ | ||
return new Item | ||
{ | ||
Drink = itemRepresentation.Drink, | ||
Milk = itemRepresentation.Milk, | ||
Size = itemRepresentation.Size | ||
}; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Restbucks.Service/Mappers/OrderRepresentationMapper.cs
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Linq; | ||
using Restbucks.Service.Domain; | ||
using Restbucks.Service.Representations; | ||
|
||
namespace Restbucks.Service.Mappers | ||
{ | ||
public class OrderRepresentationMapper | ||
{ | ||
public OrderRepresentation GetRepresentation(Order order) | ||
{ | ||
var itemMapper = new ItemRepresentationMapper(); | ||
return new OrderRepresentation | ||
{ | ||
Cost = order.Total, | ||
Items = order.Items.Select(itemMapper.GetRepresentation).ToList(), | ||
Location = order.Location, | ||
Status = order.Status, | ||
}; | ||
} | ||
} | ||
} |
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