public async Task UpdateAsync(int id, EditCompetitionInputModel input) { var competition = this.competitionsRepository.All().FirstOrDefault(x => x.Id == id); competition.Name = input.Name; competition.Description = input.Description; competition.CountryId = input.CountryId; competition.DateTime = input.DateTime; await this.competitionsRepository.SaveChangesAsync(); }
public async Task <IActionResult> Edit(int id, EditCompetitionInputModel input) { string userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (input.AddedByUserId == userId) { if (!this.ModelState.IsValid) { input.CountryItems = this.countriesService.GetAllAsKeyValuePairs(); return(this.View(input)); } await this.competitionService.UpdateAsync(id, input); return(this.RedirectToAction(nameof(this.ById), new { id })); } else { return(this.Redirect("/Competitions/All")); } }