У меня есть объект «Упражнение», определенный в моем веб-приложении ASP.NET MVC4. Я использую аутентификацию с помощью формы с классом AccountModels.cs по умолчанию.
У меня есть класс, который выглядит как
public class Exercise
{
private DateTime _DateCreated = DateTime.Now;
private UserProfile _Teacher;
public int Id{ get; set; }
public string Question { get; set; }
public int Anwser { get; set; }
public string Category { get; set; }
public int maxNbrOfAttempts { get; set; }
public string Hints { get; set; }
public virtual ICollection<Quiz> Quizzes { get; set; }
public DateTime Date
{
get { return _DateCreated; }
set { _DateCreated = value; }
}
public UserProfile Author
{
get { return _Teacher; }
set { _Teacher = value; }
}
}
Правильно ли я использую UserProfile для связи между упражнением и вошедшим в систему пользователем? Как я могу получить текущий профиль пользователя в моем контроллере?