예제 #1
0
 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));
 }
예제 #2
0
 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));
 }