public IActionResult Add_View_People(PeopleViewModel objModel) { CreatePersonViewModel createPersonModelView = new CreatePersonViewModel(); if (objModel.AddPerson != null) { if (ModelState.IsValid) { createPersonModelView = objModel.AddPerson; peopleViewModel = null; ps.Add(createPersonModelView); } else { peopleViewModel.ModelErr = "Required fields are missing"; } } if (objModel.Search != null) { peopleViewModel = ps.FindBy(objModel); } //return View("Add_View_People", peopleViewModel); return RedirectToAction(nameof(Add_View_People)); }
public Language Add(CreateLanguageViewModel createLanguageViewModel) { Language lang = new Language(); //new language to be added List <PersonLanguage> allPersonLang = new List <PersonLanguage>(); //placeholder list foreach (int id in createLanguageViewModel.ListPersonID) { lang.LanguageName = createLanguageViewModel.LanguageName; PersonLanguage personLang = new PersonLanguage(); personLang.LanguageID = lang.LanguageID; //createLanguageViewModel.LanguageID; personLang.Person = _peopleService.FindBy(id); personLang.Language = lang; personLang.PersonID = id; allPersonLang.Add(personLang); lang.PL = allPersonLang; //_personLangService.Add(id, language.LanguageID); } Language language = _languageRepo.Create(lang); return(language); }