Example #1
0
        public async Task <ActionResult> Edit(int Id)
        {
            var course = await context.GetCourseAsync(Id);

            var model = new CourseViewModel()
            {
                Date        = course.Date,
                Teacher     = course.Teacher,
                Description = course.Description,
                Name        = course.Name,
                Id          = Id
            };

            return(View(model));
        }
        public async Task <ActionResult> Enroll(int id)
        {
            if (ModelState.IsValid)
            {
                var course = await context.GetCourseAsync(id);

                if (course == null)
                {
                    return(PartialView("Error"));
                }
                var enroll = new EnrollViewModel()
                {
                    CourseId = id, CourseName = course.Name
                };
                return(View(enroll));
            }
            return(View());
        }