So we have Order which is Logic and IOrderData which connects the View and the Logic when it comes to data like properties. Order has properties of enums PayMethod and OrderStatus. How do I make properties of PayMethod and OrderStatus in IOrderData without the interface-layer knowing either Logic nor View?
Example:
Project Logic:
public class Order : IOrder, IOrderData
{
public enum PayMethod
{
iDeal,
creditcard,
PayPal
}
public enum OrderStatus
{
NotPaid,
InTheMaking,
Shipped,
Delivered,
Confirmed
}
public OrderStatus Status { get; set; }
public PayMethod Paymethod { get; set; }
Project DataInterface:
public interface IOrderData
{
public OrderStatus Status { get; set; } //doesn't work
public PayMethod Paymethod { get; set; } //doesn't work
}
My solution: I just made a new Class Library for Enums with classes of PayMethod and OrderStatus and everywhere where enums we're used I referred to the Class Library.
This code doesn't compile because your enums are members of the
Orderclass. If you move them outside the class and make them top-level members of your namespace, as stated in official documentation:This will solve the problem: