public async Task <IActionResult> EnterTime(FinishTimeViewModel finishTime) { if (!this.ModelState.IsValid) { return(this.View(finishTime)); } await this.organizersService.EnterTimeAsync(finishTime); return(this.Redirect("~/organizers/results?raceId=" + finishTime.RaceId)); }
public IActionResult EnterTime(string racerId, int raceId) { var model = new FinishTimeViewModel { RaceId = raceId, RaceTime = "00:00:00", RacerId = racerId, }; return(this.View(model)); }
public async Task EnterTimeAsync(FinishTimeViewModel finishTime) { var race = this.racesRepository.All().FirstOrDefault(x => x.Id == finishTime.RaceId); var resultInput = new Result { FinishTime = TimeSpan.ParseExact(finishTime.RaceTime.ToString(), "hh\\:mm\\:ss", CultureInfo.InvariantCulture), RaceId = finishTime.RaceId, UserId = finishTime.RacerId, }; race.Results.Add(resultInput); this.racesRepository.Update(race); await this.racesRepository.SaveChangesAsync(); }