public IActionResult AddFaculty(AddFacultyViewModel addfaculty) { if (ModelState.IsValid) { var facultyMap = _autoMapper.Map <AddFacultyViewModel, Faculty>(addfaculty); _db.Faculties.Add(facultyMap); _db.SaveChanges(); return(RedirectToAction("Index", "Deanary")); } return(View(addfaculty)); }
public IActionResult AddFaculty(AddFacultyViewModel model) { if (ModelState.IsValid) { Faculty faculty = new Faculty { FacultyCode = model.FacultyCode, FacultyName = model.FacultyName }; entityRepository.Insert(faculty); entityRepository.Save(); return(RedirectToAction("allfaculties")); } return(View(model)); }