我正在尝试设计一家音乐商店,在其中我尝试使用具有EF代码的洋葱架构优先方法。结构是否正确?
Core.Domain
namespace MusicCDStore.Core.Model
{
public class MusicCD
{
string name;
int qty;
string moviename;
string director;
string languageCategory;
float price;
int quantity;
}
}
namespace MusicCDStore.Core.Model
{
class User
{
string username;
string password;
enum userType
{
Customer=1,
Admin=0
}
}
}
namespace MusicCDStore.Core.Model
{
class Admin : User, IAdminFunctions
{
public void addMusicCD()
{
throw new NotImplementedException();
}
}
}
class Customer<T>:User,ICustomerFunctions,ISearch<T>
{
public List<MusicCD> wishList;
public void addToWishList()
{
throw new NotImplementedException();
}
public void buy()
{
throw new NotImplementedException();
}
public void getOrders()
{
throw new NotImplementedException();
}
public void searchBy(T searchType)
{
throw new NotImplementedException();
}
public void vote()
{
throw new NotImplementedException();
}
}
}
Core.Interfaces
namespace MusicCDStore.Core.Interfaces
{
interface ISearch<T>
{
void searchBy(T searchType);
}
}
namespace MusicCDStore.Core.Interfaces
{
interface ICustomerFunctions
{
void buy();
void addToWishList();
void getOrders();
void vote();
}
}
namespace MusicCDStore.Core.Interfaces
{
interface IAdminFunctions
{
void addMusicCD();
}
}
基础设施
我有AdminRepository,CustomerRepository,SearchRepository,它们将实现Domain.Interfaces中存在的接口。我也有MusicCDContext和UserDbContext类,它们将为Core.Domain中存在的实体提供与db相关的活动。
代码结构
我应该对模型进行哪些更改?