public async Task <IActionResult> Edit(int id, [Bind("CourseId,StudentId,Status,Id")] ReservedCourse reservedCourse)
        {
            if (id != reservedCourse.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _bRules.UpdateAsync(reservedCourse);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservedCourseExists(reservedCourse.Id).Result)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(await _bRules.GetCoursesAsync(), "Id", "Description", reservedCourse.CourseId);
            ViewData["StudentId"] = new SelectList(await _bRules.GetUsersAsync(), "Id", "Email", reservedCourse.StudentId);
            return(View(reservedCourse));
        }
        public async Task <IActionResult> Create([Bind("CourseId,StudentId,Status,Id")] ReservedCourse reservedCourse)
        {
            if (ModelState.IsValid)
            {
                int?idC = TempData["CourseId"] as int?;
                int?idU = TempData["userId"] as int?;
                TempData["UserId"] = idU;

                if ((await _bRules.GetAllAsync()).Where(u => u.StudentId == idU.Value).Where(c => c.CourseId == idC.Value).FirstOrDefault() == null)
                {
                    reservedCourse.CourseId  = idC.Value;
                    reservedCourse.StudentId = idU.Value;
                    reservedCourse.Status    = Status.Requested;
                    await _bRules.CreateAsync(reservedCourse);
                }
                return(RedirectToAction("Index", "Courses"));
            }

            ViewData["CourseId"]  = new SelectList(await _bRules.GetCoursesAsync(), "Id", "Description", reservedCourse.CourseId);
            ViewData["StudentId"] = new SelectList(await _bRules.GetUsersAsync(), "Id", "Email", reservedCourse.StudentId);
            return(View(reservedCourse));
        }