public ActionResult SaveLecture(UserInformation user, LectureForEditing lecture) { if (user != null) { if (user.IsStudent) { return View("Students limitations"); } else { try { if (!ModelState.IsValid) return View("EditLecture", lecture); else { Lecture lect = new Lecture() { ID = lecture.ID, Name = lecture.Name, TopicId = lecture.TopicId, OrderNumber = lecture.OrderNumber, Homework = lecture.Homework, LectureContent = lecture.LectureContent }; _repository.SaveLecture(lect); return RedirectToAction("EditTopic", "Topic", new { topicId = lecture.TopicId }); } } catch (Exception e) { return View("Error"); } } } else return View("UnauthorizedAccess"); }
public ActionResult EditLecture(UserInformation user, Guid lectureId) { if (user != null) { if (user.IsStudent) { return View("Students limitations"); } else { try { if (!CheckIfLecturerHasAccess(user, lectureId)) return View("AccessDenied"); else { //Check if user can edit this lecture Lecture l = _repository.Lectures.Where(x => x.ID == lectureId).First(); LectureForEditing lect = new LectureForEditing() { ID = lectureId, Homework = l.Homework, LectureContent = l.LectureContent, OrderNumber = l.OrderNumber, TopicId = l.TopicId, Name = l.Name }; return View(lect); } } catch (Exception e) { return View("Error"); } } } else return View("UnauthorizedAccess"); }