예제 #1
0
 public ActionResult Edit(Student Student)
 {
     if (ModelState.IsValid)
     {
         var studentList = _StudentBLL.GetAll().TableList;
         var OldStd      = studentList.Exists(s => s.StudentName == Student.StudentName && s.StudentId != Student.StudentId);
         if (OldStd)
         {
             ModelState.AddModelError(string.Empty, "Student Name already exists.");
             return(View());
         }
         else
         {
             if (Student.StudentId == 0)
             {
                 Student = _StudentBLL.Add(Student.StudentName);
             }
             else
             {
                 _StudentBLL.Edit(Student);
             }
         }
     }
     return(RedirectToAction("Index"));
 }