public IActionResult AddPhrases(int phraseGroupId) { var phrasesAddPhrasesViewModel = new PhrasesAddPhrasesViewModel() { PhraseGroupId = phraseGroupId }; return(View(phrasesAddPhrasesViewModel)); }
public async Task <IActionResult> AddPhrases(PhrasesAddPhrasesViewModel phrasesAddPhrasesViewModel) { using (var daef = new DentistAssistantContext()) { //var newParases = (from p in phrasesAddPhrasesViewModel.Description // select new Phrases() // { // Description = p // }).ToList(); //daef.Phrases.AddRange(newParases); var phraseGroup = daef.PhraseGroups.Find(phrasesAddPhrasesViewModel.PhraseGroupId); foreach (string description in phrasesAddPhrasesViewModel.Description) { phraseGroup.Phrases.Add(new Phrases() { Description = description }); } await daef.SaveChangesAsync(); return(Redirect(Url.Action("Index", "Phrases", new { phraseGroupId = phrasesAddPhrasesViewModel.PhraseGroupId }))); } }