private void InitializeSubjects() { _subjectsDictionary.Clear(); foreach (var subject in _subjectService.All()) { _subjectsDictionary["" + subject.Id] = subject.Name; TempData["" + subject.Id] = subject.Name; } }
/* public ActionResult ChooseSubject() * { * //ViewBag.Title = "בחר תת-נושא"; * * return RedirectToAction("ChooseSubSubject"); * } */ public ActionResult ChooseSubSubject(string subjName) { try { if (_textService.All().Where(x => x.Name == subjName).Count() > 0) { Session["textName"] = subjName; TempData["textName"] = subjName; return(RedirectToAction("GotoSmartTextBox", 1)); } ViewBag.Title = subjName; List <Text> texts = new List <Text>(); List <Tuple <string, string, Text> > textTuple = new List <Tuple <string, string, Text> >(); string userid = User.Identity.GetUserId(); foreach (var std in _studentService.All().Include(x => x.Homeworks.Select(t => t.Text))) { if (std.ApplicationUserId.Equals(userid)) { student = std; break; } } Guid tmpSubjectGuid = _subjectServiceService.All().Where(x => x.Name == subjName).FirstOrDefault().Id; Subject tempSubj = _subjectServiceService.GetByName(subjName); List <Guid> textsIDList = new List <Guid>(); texts = _textService.All().Where(x => x.Subject_Id == tempSubj.Id).ToList(); if (student.Homeworks.Where(x => x.Text.Subject_Id == tmpSubjectGuid).Count() != 0) { TempData["HomeWorks"] = "true"; foreach (var hw in student.Homeworks) { if (texts.Contains(hw.Text)) { textsIDList.Add(hw.Text.Id); Tuple <string, string, Text> t = new Tuple <string, string, Text>(hw.Created_By.Name, hw.Deadline.ToString(), hw.Text); textTuple.Add(t); } } } else { TempData["HomeWorks"] = "false"; foreach (var hw in student.Homeworks) { Tuple <string, string, Text> t = new Tuple <string, string, Text>(hw.Created_By.Name, hw.Deadline.ToString(), hw.Text); textTuple.Add(t); } } TextsNotificationsViewModel model = new TextsNotificationsViewModel(); model.Texts = texts; model.TextsIDList = textsIDList; model.TextsTuple = textTuple; return(View("Texts", model)); } catch (Exception e) { return(RedirectToAction("Index")); } }