public ActionResult Create(TeachingTopicViewModel model)
        {
            //get lecturer
            var role  = (from r in _context.Roles where r.Name.Contains("Lecturer") select r).FirstOrDefault();
            var users = _context.Users.Where(x => x.Roles.Select(y => y.RoleId).Contains(role.Id)).ToList();

            //get topic
            var topics = _context.Topics.ToList();


            if (ModelState.IsValid)
            {
                _context.TeachingTopics.Add(model.TeachingTopic);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            var TeachingTopicVM = new TeachingTopicViewModel()
            {
                Topics        = topics,
                Lecturers     = users,
                TeachingTopic = new TeachingTopic()
            };

            return(View(TeachingTopicVM));
        }
        public ActionResult Edit(int id)
        {
            var ttInDb = _context.TeachingTopics.SingleOrDefault(p => p.Id == id);

            if (ttInDb == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new TeachingTopicViewModel
            {
                TeachingTopic = ttInDb,
                Topics        = _context.Topics.ToList(),
            };

            return(View(viewModel));
        }
        public ActionResult Create()
        {
            //get lecturer
            var role  = (from r in _context.Roles where r.Name.Contains("Lecturer") select r).FirstOrDefault();
            var users = _context.Users.Where(x => x.Roles.Select(y => y.RoleId).Contains(role.Id)).ToList();

            //get topic
            var topics = _context.Topics.ToList();

            var TeachingTopicVM = new TeachingTopicViewModel()
            {
                Topics        = topics,
                Lecturers     = users,
                TeachingTopic = new TeachingTopic()
            };

            return(View(TeachingTopicVM));
        }