Owneat Technical Guide main Help

Class Order

Namespace: Ordering.Domain.Aggregates.OrderAggregate
Assembly: Ordering.Domain.dll

[Table("Orders")] public sealed class Order : Entity, IAggregateRoot, IAuditable

Inheritance

object ← Entity ← Order

Implements

IAggregateRoot, IAuditable

Inherited Members

Entity.Id, Entity.CreatedAt, Entity.UpdatedAt, Entity.DomainEvents, object.Equals\(object?\), object.Equals\(object?, object?\), object.GetHashCode\(\), object.GetType\(\), object.ReferenceEquals\(object?, object?\), object.ToString\(\)

Constructors

Order\(\)

public Order()

Properties

CustomerId

The Ordering.Domain.Aggregates.Customer that placed the Ordering.Domain.Aggregates.OrderAggregate.Order.

[ForeignKey("CustomerId")] public Guid CustomerId { get; init; }

Property Value

Guid

IsTreatmentOver

Bool that says if the order is ended for the restaurant.

public bool IsTreatmentOver { get; }

Property Value

bool

LineItems

The list of products contained in the Ordering.Domain.Aggregates.OrderAggregate.Order.

public IEnumerable<OrderLineItem> LineItems { get; }

Property Value

IEnumerable < OrderLineItem \>

NeedsToBePaid

Bool that says if an order needs to be paid.

public bool NeedsToBePaid { get; init; }

Property Value

bool

PaymentState

The current state of the Ordering.Domain.Aggregates.OrderAggregate.Order.

public OrderPaymentState? PaymentState { get; }

Property Value

OrderPaymentState?

RestaurantId

The Restaurant where is placed the Ordering.Domain.Aggregates.OrderAggregate.Order.

public Guid RestaurantId { get; init; }

Property Value

Guid

State

The current state of the Ordering.Domain.Aggregates.OrderAggregate.Order.

public OrderState State { get; set; }

Property Value

OrderState

TableId

The Ordering.Domain.Aggregates.TableAggregate.Table where is placed the Ordering.Domain.Aggregates.OrderAggregate.Order.

[ForeignKey("TableId")] public Guid TableId { get; set; }

Property Value

Guid

TotalPrice

The total price of all products included in the Ordering.Domain.Aggregates.OrderAggregate.Order.

[NotMapped] public double TotalPrice { get; }

Property Value

double

UnpaidTotalPrice

The total price of all products included in the Ordering.Domain.Aggregates.OrderAggregate.Order.

[NotMapped] public double UnpaidTotalPrice { get; }

Property Value

double

Methods

AcknowledgeCategory\(string\)

public void AcknowledgeCategory(string categoryName)

Parameters

categoryName string

AcknowledgeServingPeriod\(ServingPeriod\)

Method that marks all the order line items of the order as acknowledged.

public void AcknowledgeServingPeriod(ServingPeriod servingPeriod)

Parameters

servingPeriod ServingPeriod

AddNewLineItem\(OrderLineItem\)

Method that add a product to the Ordering.Domain.Aggregates.OrderAggregate.Order.LineItems list of the Ordering.Domain.Aggregates.OrderAggregate.Order.

public void AddNewLineItem(OrderLineItem lineItem)

Parameters

lineItem OrderLineItem

The product to add.

AddProducts\(IEnumerable<OrderLineItem\>\)

Method that add a product to the Ordering.Domain.Aggregates.OrderAggregate.Order.LineItems list of the Ordering.Domain.Aggregates.OrderAggregate.Order.

public void AddProducts(IEnumerable<OrderLineItem> products)

Parameters

products IEnumerable < OrderLineItem \>

The products to add.

CalculateIfPaymentIsNeededForOrder\(\)

Method that initialize state depending on pre-payment condition.

public void CalculateIfPaymentIsNeededForOrder()

Cancel\(\)

Method that cancel an order.

public void Cancel()

CancelItemWithId\(Guid\)

Method that cancel an order item.

public Result<Unit> CancelItemWithId(Guid itemToCancelGuid)

Parameters

itemToCancelGuid Guid

Returns

Result<Unit\>

CreateNew\(Guid, Guid, Guid, bool, bool, List<OrderLineItem\>\)

Method that create an Ordering.Domain.Aggregates.OrderAggregate.Order.

public static Order CreateNew(Guid customerId, Guid tableId, Guid restaurantId, bool customerNeedsToPayFirst, bool customerHasToPay, List<OrderLineItem> items)

Parameters

customerId Guid

Ordering.Domain.Aggregates.Customer that placed the Ordering.Domain.Aggregates.OrderAggregate.Order.

tableId Guid

Table on which was placed the Ordering.Domain.Aggregates.OrderAggregate.Order.

restaurantId Guid

Restaurant on which was placed the Ordering.Domain.Aggregates.OrderAggregate.Order.

customerNeedsToPayFirst bool

Book that says if the customer needs to pay first.

customerHasToPay bool

Bool that says if the customer will have to pay (payment enabled or not).

items List < OrderLineItem \>

The ordered line items to compose the order.

Returns

Order

The created Ordering.Domain.Aggregates.OrderAggregate.Order.

Finish\(\)

Mark the order to finished state.

public void Finish()

GetOrderProducts\(\)

Method that get all the Ordering.Domain.Aggregates.OrderAggregate.OrderLineItems of the Ordering.Domain.Aggregates.OrderAggregate.Order.

public IEnumerable<OrderLineItem> GetOrderProducts()

Returns

IEnumerable < OrderLineItem \>

GetPaidItems\(\)

Method that get all the Ordering.Domain.Aggregates.OrderAggregate.OrderLineItems of that had been paid.

public IEnumerable<OrderLineItem> GetPaidItems()

Returns

IEnumerable < OrderLineItem \>

MarkAllItemsAsAcknowledged\(\)

Method that marks all the order line items of the order as acknowledged.

public void MarkAllItemsAsAcknowledged()

MarkAnItemAsAcknowledged\(Guid\)

Method that marks a unique order line item of the order as acknowledged.

public void MarkAnItemAsAcknowledged(Guid acknowledgedItemId)

Parameters

acknowledgedItemId Guid

OrderHasBeenCanceled\(\)

Method that says if an order is canceled.

public bool OrderHasBeenCanceled()

Returns

bool

RemoveLineItemFromBilling\(OrderLineItem, int\)

Method that remove the line item from the current billing.

public void RemoveLineItemFromBilling(OrderLineItem lineItem, int newQuantity)

Parameters

lineItem OrderLineItem

newQuantity int

RemoveProduct\(OrderLineItem\)

Method that remove a product from the Ordering.Domain.Aggregates.OrderAggregate.Order.LineItems list of the Ordering.Domain.Aggregates.OrderAggregate.Order.

public void RemoveProduct(OrderLineItem lineItem)

Parameters

lineItem OrderLineItem

The product to remove.

Serve\(\)

Method that serve an order.

public void Serve()

ServeAcknowledgedItemsByCategory\(string\)

public void ServeAcknowledgedItemsByCategory(string categoryName)

Parameters

categoryName string

ServeAcknowledgedItemsByServingPeriod\(ServingPeriod\)

Method that validate all the order line items of the order by the serving period.

public void ServeAcknowledgedItemsByServingPeriod(ServingPeriod servingPeriod)

Parameters

servingPeriod ServingPeriod

ServeTheLineItemWithId\(Guid\)

Method that serve a single order line item of the order.

public void ServeTheLineItemWithId(Guid servedItemId)

Parameters

servedItemId Guid

SwitchToTheTableWithId\(Guid, Guid\)

public void SwitchToTheTableWithId(Guid movingCustomerId, Guid newTableId)

Parameters

movingCustomerId Guid

newTableId Guid

TogglePayingCustomerId\(Guid, Guid\)

Method that toggle an order line item paying customer id.

public Result<OrderLineItem> TogglePayingCustomerId(Guid orderLineItemId, Guid payingCustomerId)

Parameters

orderLineItemId Guid

payingCustomerId Guid

Returns

Result< OrderLineItem \>

UnlinkEveryPaidItemsFromTheCustomerWithId\(Guid\)

Method that reset the paying customer of the order line items with the given id.

public void UnlinkEveryPaidItemsFromTheCustomerWithId(Guid customerToRemoveGuid)

Parameters

customerToRemoveGuid Guid

Last modified: 21 May 2024