Exemple #1
0
        public async Task <ActionResult> Index()
        {
            var list = new List <CourseDetailsViewModel>();

            if (ModelState.IsValid)
            {
                var courses = await context.GetAllCoursesAsync();

                foreach (var i in courses)
                {
                    list.Add(new CourseDetailsViewModel
                    {
                        Id                = i.Id,
                        Date              = i.Date,
                        Description       = i.Description,
                        FilledToCapacity  = i.FilledToCapacity,
                        Name              = i.Name,
                        NumOfParticipants = i.NumberOfParticipants,
                        Teacher           = i.Teacher
                    });
                }
            }
            return(View(list));
        }
        public async Task <ActionResult> Index()
        {
            var list = new List <CourseViewModel>();

            if (ModelState.IsValid)
            {
                var courses = await context.GetAllCoursesAsync();

                foreach (var i in courses)
                {
                    list.Add(new CourseViewModel
                    {
                        Id          = i.Id,
                        Date        = i.Date,
                        Description = i.Description,
                        Name        = i.Name,
                        Teacher     = i.Teacher
                    });
                }
            }
            return(View(list));
        }