public ActionResult Lecture(Guid key)
        {
            Lecture lecture = _lectureService.GetLecture(key);

            if (lecture == null)
            {
                RedirectToRoute("Default");
            }
            var student = _studentService.LectureStudents(lecture);

            return(View("Index", student));
        }
示例#2
0
        // GET: Lectures/Details/5
        public ActionResult Details(Guid?key)
        {
            if (key == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lecture lecture = _lectureService.GetLecture((Guid)key);

            if (lecture == null)
            {
                return(HttpNotFound());
            }
            return(View(lecture));
        }
        public ActionResult Index(int id)
        {
            var model = lectureService.GetLecture(id);

            if (model == null)
            {
                return(View());
            }
            else
            {
                return(View(model));
            }
        }
示例#4
0
        public IActionResult Update(string lectureId, string courseId, string title, string description,
                                    string preparation, bool completed, bool free, TimeSpan from, TimeSpan to, EnumList.Days day, DateTime lectureDate)
        {
            //Check if the day match the date
            if (_context.Lectures.Where(x => x.CourseId == courseId).Where(x => x.Id != lectureId).Any(x => x.Date == lectureDate))
            {
//                return BadRequest("The date already taken");
                return(BadRequest("dateTaken"));
            }

            if (lectureDate.DayOfWeek.ToString() != day.ToString())
            {
                return(BadRequest("dayNotMatch"));
            }

            if (to < from)
            {
                return(BadRequest("endTimeHigher"));
            }


            var lecture = _lectureService.GetLecture(lectureId);

            if (lecture == null)
            {
                return(BadRequest("errorHappened"));
            }

            var oldDate = lecture.Date;

            lecture.Title       = title;
            lecture.Description = description;
            lecture.Preparation = preparation;
            lecture.Completed   = completed;
            lecture.Free        = free;
            lecture.Day         = day;
            lecture.Date        = lectureDate;
            lecture.From        = from;
            lecture.To          = to;

            try
            {
                _context.Lectures.Update(lecture);
                _context.SaveChanges();
            }
            catch
            {
                return(BadRequest("errorHappened"));
            }


            if (oldDate != lectureDate)
            {
                _courseService.ReorderCourseLectures(lecture.CourseId);
            }

            return(Ok());
        }
        public ActionResult Index(int id)
        {
            var model = lectureService.GetLecture(id);

            model.Images = imageService.GetItemImages(model.Id);
            model.Image  = imageService.GetItemImage(model.Id);

            if (model == null)
            {
                return(View());
            }
            else
            {
                return(View(model));
            }
        }
        public ActionResult DeleteLecture(int id = 0)
        {
            var user = Session["User"] as User;

            if (user == null)
            {
                return(RedirectToAction("Login", "UserRegistration"));
            }
            else
            {
                if (id != 0)
                {
                    var lecture = lectureService.GetLecture(id);
                    if (lecture != null)
                    {
                        lectureService.DeleteLecture(lecture);
                    }
                    id = 0;
                }
                var lectures = lectureService.GetAllLecture();
                return(View(lectures));
            }
        }
示例#7
0
        public ActionResult Edit(Lecture lecture)
        {
            var model = lectureService.GetLecture(lecture.Id);

            return(View(model));
        }