Nest控制器的最佳实践

时间:2018-06-12 00:32:01

标签: c# asp.net-mvc

在我的应用程序中,我有2个课程电话,地址。两者都与我的数据库中的表相关(使用实体框架),并且具有相应的控制器和CRUD方法以及相应的视图

public class Phone
{
    [Key]
    public int PhoneID { get; set; }
    public PHONETYPE PhoneType { get; set; }}//i.e: mobile, private, office, fax
    public string OriginalNumber{ get; set; }
    public string IndexedNumber{ get; set; }
    public bool IsActive{ get; set; }
    public DateTime LastUpdate { get; set; }
}

public class Address
{
   [Key]
    public int AddressID { get; set; }
    public int ADDRESSTYPE { get; set; } //enum i.e.: billing, delivery etc
    public string AddressLine1 { get; set; }
    public string AddressLine2 { get; set; }
    public int CityID { get; set; }
    public int StateID { get; set; }
    public int PostCodeID { get; set; }
    public int CountryID { get; set; }
    public bool IsActive { get; set; }
    public DateTime LastUpdate { get; set; }
}

现在,我即将创建另外两个类,它们是相应的控制器,视图和表,它们将如下所示:

public class Student
{
    String name,
    String mainSubject;
    int gender;
    ……
    List<int> phoneID;
    List<int> addressID;
    ….
}

public class School
{
    String name,
    Bool isGoverment
    …..
    List<int> PhoneID;
    List<int> AddressID;
    ….
}

我的问题:
我想正确创建学生和学校控制器。如你所见,每个人都有地址和电话。

每个学校\学生可能有超过1个电话或地址:一旦最终用户进入学校\学生详细信息,他将可以选择“添加另一个地址”\“添加另一个电话”

对Student \ School控制器进行编码的方式是什么,所以他们会使用我已有的电话和地址控制器?我读到了关于ChildAction,路由属性的内容。我是否需要使用其中任何一种来实现它?或者你会做什么?

0 个答案:

没有答案
相关问题