public async Task <IActionResult> Create(CreateWordViewModel model) { Word word = this.mapper.Map <Word>(model); await this.wordsService.Create(word); int wordId = this.wordsService.GetByTitle(model.Title).Id; if (model.Meanings.Any(m => m != null)) { await this.meaningService.CreateMeanings(wordId, model.Meanings.Where(m => m != null).ToList()); } if (model.Sentences.Any(m => m != null)) { await this.sentenceService.CreateSentences(word.Id, model.Sentences.Where(s => s != null).ToList()); } this.TempData["SuccessfullCreate"] = $"You have successfully created the word \"{word.Title}\""; return(this.RedirectToAction("AllWords")); }
public ActionResult Create() { CreateWordViewModel model = new CreateWordViewModel(); return(this.View(model)); }