public async Task <IActionResult> Edit(int id, FlightCompanyViewModel companyViewModel) { if (id != companyViewModel.Id) { return(this.NotFound()); } if (!this.ModelState.IsValid) { return(this.View(companyViewModel)); } try { await this.flightCompaniesService.EditAsync(id, companyViewModel); } catch (DbUpdateConcurrencyException) { if (!this.FlightCompanyExists(companyViewModel.Id)) { return(this.NotFound()); } else { throw; } } return(this.RedirectToAction(nameof(this.Index))); }
public async Task EditAsync(int id, FlightCompanyViewModel input) { var company = this.flightCompaniesRepository.All().FirstOrDefault(x => x.Id == id); company.Name = input.Name; company.IsDeleted = input.IsDeleted; this.flightCompaniesRepository.Update(company); await this.flightCompaniesRepository.SaveChangesAsync(); }