【发布时间】:2017-04-27 08:53:20
【问题描述】:
我的项目中有 Course, Offered Course , Course Registration 表, Section Table 我想实现每个用户的课程注册系统。这是我项目的数据库图。 我想像这样实现这个功能。我没有实现
的这个功能 class time . public class Course
{
[Key]
public int CourseId { get; set; }
[Required]
public string Name { get; set; }
public string Code { get; set; }
public string Credit { get; set; }
public DateTime RegDate { get; set; }
public string PreCourse { get; set; }
public int DepartmentId { get; set; }
[ForeignKey("DepartmentId")]
public virtual Department Department { get; set; }
public virtual ICollection<OfferedCourse> OfferedCourses { get; set; }
}
这是我的课程模型,
public class Department
{
[Key]
public int DepartmentId { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Code { get; set; }
public virtual ICollection<ApplicationUser> ApplicationUsers { get; set; }
public virtual ICollection<Course> Courses { get; set; }
}
这是我的部门模型,
public class OfferedCourse
{
[Key]
public int OfferedCourseId { get; set; }
public int Capacity { get; set; }
public bool Status { get; set; }
public int CourseId { get; set; }
[ForeignKey("CourseId")]
public virtual Course Course { get; set; }
public string TeacherId { get; set; }
[ForeignKey("TeacherId")]
public virtual ApplicationUser ApplicationUser { get; set; }
public int SectionId { get; set; }
[ForeignKey("SectionId")]
public virtual Section Section { get; set; }
public int SemesterId { get; set; }
[ForeignKey("SemesterId")]
public virtual Semester Semester { get; set; }
public virtual ICollection<CourseRegistration> CourseRegistrations { get; set; }
}
这是我每学期开设的课程。
public class Section
{
[Key]
public int SectionId { get; set; }
public string Title { get; set; }
}
这是我的部分模型。在这个项目中,我使用 asp.net 身份框架来管理像老师、学生这样的用户。但是尝试了很多方法 管理课程注册视图中的单选按钮。我该如何实现这个功能,因为我有不同类型的数据,比如部分和课程名称我该如何处理这个
【问题讨论】:
-
您的图片显示的是复选框,而不是单选按钮。假设您确实想按照模型的建议选择多个课程,请参阅 this answer 以获取视图模型和视图的典型示例
-
是的,我需要单选按钮.. 我该怎么做.. 我想我需要一个视图模型,但我该如何实现
-
抱歉,无法从您所展示的内容中理解。 “理学士……”是您的
Section.Title财产吗?它下面的 3 项是OfferedCourses对应的Section你只想选择这 3 项中的一项吗? -
每个主题都有很多部分,如 A、B 或 C、d。我想这样显示:Algorithm and al section of algorir using radio button
标签: asp.net-mvc razor view asp.net-mvc-5 viewmodel