public async Task <IActionResult> Edit(int id, [Bind("EntryId,AthletesFK,SportsTestFK,CreatedBy,CreatedOn,UpdatedBy,UpdatedOn,Distance")] SportTestAthletes sportTestAthletes)
        {
            if (id != sportTestAthletes.EntryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (User.IsInRole("Coach") == true)
                    {
                        sportTestAthletes.UpdatedOn = DateTime.Now;
                        sportTestAthletes.UpdatedBy = this.AspNetUser.EntryId;
                        _context.Update(sportTestAthletes);
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        ModelState.AddModelError("Coach", "Only Coach permitted to add data");
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SportTestAthletesExists(sportTestAthletes.EntryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect($@"\SportsTests\Details\{sportTestAthletes.SportsTestFK}"));
            }
            ViewData["AthletesFK"]   = new SelectList(_context.atheleteViewModels.FromSql("prAthlete_Get"), "EntryId", "Athlete", sportTestAthletes.AthletesFK);
            ViewData["SportsTestFK"] = new SelectList(_context.sportsTests, "EntryID", "EntryID", sportTestAthletes.SportsTestFK);
            return(View(sportTestAthletes));
        }
        public async Task <IActionResult> Create([Bind("EntryId,AthletesFK,SportsTestFK,CreatedBy,CreatedOn,UpdatedBy,UpdatedOn,Distance")] SportTestAthletes sportTestAthletes)
        {
            if (ModelState.IsValid)
            {
                if (User.IsInRole("Coach") == true)
                {
                    sportTestAthletes.CreatedOn = DateTime.Now;
                    sportTestAthletes.CreatedBy = this.AspNetUser.EntryId;
                    _context.Add(sportTestAthletes);
                    await _context.SaveChangesAsync();

                    return(Redirect($@"\SportsTests\Details\{sportTestAthletes.SportsTestFK}"));
                }
                else
                {
                    ModelState.AddModelError("Coach", "Only Coach permitted to add data");
                }
            }
            ViewData["AthletesFK"]   = new SelectList(_context.atheleteViewModels.FromSql("prAthlete_Get"), "EntryId", "Athlete", sportTestAthletes.AthletesFK);
            ViewData["SportsTestFK"] = new SelectList(_context.sportsTests, "EntryID", "EntryID", sportTestAthletes.SportsTestFK);
            return(View(sportTestAthletes));
        }