// Create public bool AddSentence(SentenceCreate model) { var entity = new Sentence() { UserId = _userId, SentenceContent = model.SentenceContent, SentenceTranslation = model.SentenceTranslation, WordId = _wordId }; _context.Sentences.Add(entity); return(_context.SaveChanges() == 1); }
public ActionResult Create(int languageId, int wordId, SentenceCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateSentenceService(wordId); if (service.AddSentence(model)) { TempData["SaveResult"] = "Sentence added successfully."; return(RedirectToAction("Details", "Word", new { languageId, id = wordId })); } ModelState.AddModelError("", "Sentence was not added."); return(View(model)); }