public async Task <IActionResult> Create([Bind("ID,user_id,create_time,Trun_time,Trun_score,Gunrun_time,Gunrun_score,score,age")] SpeedAbility speedAbility, string type)
        {
            speedAbility.create_time = DateTime.Now;

            speedAbility.Trun_score = (int)speedAbility.Trun_time * 20 - 160;
            var s = await _context.Gunrun_Score.SingleOrDefaultAsync(m => m.age == speedAbility.age && m.num == speedAbility.Gunrun_time);

            speedAbility.Gunrun_score = s.score * 20 + 40;

            speedAbility.score = (speedAbility.Trun_score + speedAbility.Gunrun_score) / 2;

            if (type == "yes")
            {
                _context.Add(speedAbility);
                await _context.SaveChangesAsync();
            }

            Result res = new Result();

            res.Trunnum   = speedAbility.Trun_score.ToString();
            res.Gunrunnum = speedAbility.Gunrun_score.ToString();

            JsonResult result = Json(res);

            return(result);
        }
        public async Task <IActionResult> Edit(string id, [Bind("ID,user_id,create_time,Trun_time,Trun_score,Gunrun_time,Gunrun_score,score")] SpeedAbility speedAbility)
        {
            if (id != speedAbility.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(speedAbility);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpeedAbilityExists(speedAbility.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(speedAbility));
        }
 public SpeedList()
 {
     lastspeed = new SpeedAbility();
     list      = new List <SpeedAbility>();
     time      = new List <string>();
     Truntime  = new List <string>();
     Gruntime  = new List <string>();
 }