public void PopulateTopicsDropDownList(StudyFriendContext _context,
                                               object selectedTopic = null)
        {
            var userId      = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var topicsQuery = from t in _context.Topic
                              where t.UserId == userId
                              orderby t.Name
                              select t;

            TopicNameSL = new SelectList(topicsQuery.AsNoTracking(),
                                         "TopicID", "Name", selectedTopic);
        }
        public void PopulateQuestionsDropDownList(StudyFriendContext _context,
                                                  object selectedQuestion = null)
        {
            var userId         = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var questionsQuery = from q in _context.Question
                                 join t in _context.Topic
                                 on q.TopicID equals t.TopicID
                                 where t.UserId == userId
                                 select q;

            QuestionBodySL = new SelectList(questionsQuery.AsNoTracking(),
                                            "QuestionID", "Body", selectedQuestion);
        }
Example #3
0
        public void FindTopic_ByUserId()
        {
            using (var db = new StudyFriendContext(Utilities.TestDbContextOptions()))
            {
                string user_id = "test_id";
                var    topics  = new Topic[]
                {
                    new Topic {
                        Name = "JavaScript", UserId = user_id
                    }
                };
                foreach (Topic t in topics)
                {
                    db.Topic.Add(t);
                }
                db.SaveChanges();

                var topic = (from t in db.Topic
                             where t.UserId == user_id
                             select t).Single();

                Assert.Equal(topic.UserId, user_id);
            }
        }
Example #4
0
 public CreateModel(StudyFriendContext context)
 {
     _context = context;
 }
Example #5
0
 public DetailsModel(StudyFriendContext context)
 {
     _context = context;
 }
Example #6
0
 public IndexModel(StudyFriendContext context)
 {
     _context = context;
 }
Example #7
0
 public IndexModel(StudyFriendContext context,
                   UserManager <ApplicationUser> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Example #8
0
 public DeleteModel(StudyFriendContext context)
 {
     _context = context;
 }
Example #9
0
 public EditModel(StudyFriendContext context)
 {
     _context = context;
 }