// GET: PracticeSessions/Create
        public IActionResult Create()
        {
            //instance of view model
            ScheduleASession vm = new ScheduleASession();

            //two select list items for methods and instruments
            vm.ListOfInstruments = _context.Instrument.Select(i => new SelectListItem
            {
                Value = i.Id.ToString(),
                Text  = i.Name
            }).ToList();
            vm.ListOfPracticeMethods = _context.PracticeMethod.Select(i => new SelectListItem
            {
                Value = i.Id.ToString(),
                Text  = i.Name
            }).ToList();
            vm.ListOfInstruments.Insert(0, new SelectListItem()
            {
                Value = "0",
                Text  = "Please choose an Instrument"
            });
            vm.ListOfPracticeMethods.Insert(0, new SelectListItem()
            {
                Value = "0",
                Text  = "Please choose your method of Practicing"
            });
            return(View(vm));
        }
        public async Task <IActionResult> Edit(int id, ScheduleASession vm)
        {
            if (id != vm.practiceSession.Id)
            {
                return(NotFound());
            }
            ModelState.Remove("PracticeSession.ratethisSession");
            ModelState.Remove("PracticeSession.UserId");
            if (ModelState.IsValid)
            {
                try
                {
                    var user = await GetCurrentUserAsync();

                    vm.practiceSession.UserId = user.Id;
                    _context.Update(vm.practiceSession);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PracticeSessionExists(vm.practiceSession.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(vm));
        }
        //a new method for when a session has passed, basically another edit
        public async Task <IActionResult> ReviewIt(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ScheduleASession vm = new ScheduleASession();

            var practiceSession = await _context.PracticeSession.FindAsync(id);

            if (practiceSession == null)
            {
                return(NotFound());
            }

            return(View(practiceSession));
        }
        public async Task <IActionResult> Create(ScheduleASession vm)
        {
            //removing rating from Model state until the session has passed
            ModelState.Remove("practiceSession.ratethisSession");
            ModelState.Remove("PracticeSession.UserId");
            if (ModelState.IsValid)
            {
                var user = await GetCurrentUserAsync();

                vm.practiceSession.UserId = user.Id;
                _context.Add(vm.practiceSession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { id = vm.practiceSession.Id.ToString() }));
            }
            return(View(vm));
        }
        // GET: PracticeSessions/Edit/5
        //very similar to create methods
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ScheduleASession vm = new ScheduleASession();

            vm.ListOfInstruments = _context.Instrument.Select(i => new SelectListItem
            {
                Value = i.Id.ToString(),
                Text  = i.Name
            }).ToList();
            vm.ListOfPracticeMethods = _context.PracticeMethod.Select(i => new SelectListItem
            {
                Value = i.Id.ToString(),
                Text  = i.Name
            }).ToList();
            vm.ListOfInstruments.Insert(0, new SelectListItem()
            {
                Value = "0",
                Text  = "Please choose an Instrument"
            });
            vm.ListOfPracticeMethods.Insert(0, new SelectListItem()
            {
                Value = "0",
                Text  = "Please choose your method of Practicing"
            });
            var practiceSession = await _context.PracticeSession.FindAsync(id);

            if (practiceSession == null)
            {
                return(NotFound());
            }
            vm.practiceSession = practiceSession;
            return(View(vm));
        }