Exemplo n.º 1
0
 public ActionResult Edit(DAL.StudentDAL std)
 {
     if (ModelState.IsValid)
     {
         Student = bll.getByID(std.ID);
         DAL.StudentDAL nameAlreadyExists = new DAL.StudentDAL();
         nameAlreadyExists = bll.getAll().Where(s => s.fname == std.fname).FirstOrDefault();
         if (std != null)
         {
             if ((nameAlreadyExists != null) && (Student.ID != nameAlreadyExists.ID))
             {
                 ModelState.AddModelError("fname", "Student Name Already Exists.");
             }
             else
             {
                 bll.Edit(std);
             }
         }
         else
         {
             if (nameAlreadyExists != null)
             {
                 ModelState.AddModelError("fname", "Student Name Already Exists.");
             }
             else
             {
                 bll.Add(Student);
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(std));
 }