public async Task <IActionResult> Edit(int id, string order = "createdOn", int currentPage = 1) { Word word = await this.wordsService.GetByIdAsync(id); EditWordViewModel model = this.mapper.Map <EditWordViewModel>(word); model.Order = order; model.CurrentPage = currentPage; // Task.WaitAll(); return(this.View(model)); }
public async Task <IActionResult> Edit(EditWordViewModel model) { Word word = await this.wordsService.GetByIdAsync(model.Id); word.Title = model.Title; word.PartOfSpeech = model.PartOfSpeech; await this.wordsService.Update(word); await this.meaningService.Update(model.Meanings.Select(m => m.Id).ToList(), model.Meanings.Select(m => m.Content).ToList()); if (model.Sentences != null) { await this.sentenceService.Update(model.Sentences.Select(s => s.Id).ToList(), model.Sentences.Select(s => s.Content).ToList()); } this.TempData["SuccessfullEdit"] = $"{word.Title} {word.PartOfSpeech.ToString()}"; Task.WaitAll(); return(this.RedirectToAction("AllWords", new { order = model.Order, currentPage = model.CurrentPage })); }