public ActionResult RegisteredStudent(Regestration studentRegestration)
 {
     if (ModelState.IsValid)
     {
         CardDAO Card_DAO = new CardDAO();
         if (Card_DAO.ISExsistCardDate(studentRegestration.CardNumber))
         {
             RegestrationDAO Registrator = new RegestrationDAO();
             if (Registrator.IsCardUnsoldAndUnRegisteredWhileRegitered(studentRegestration.CardNumber))
             {
                 Registrator.RegisterStudent(studentRegestration);
                 return(View(studentRegestration));
             }
             else
             {
                 ModelState.AddModelError("", "The Card is already sold or the card number is invalid.");
                 return(View("RegisterStudent"));
             }
         }
         else
         {
             ModelState.AddModelError("", "There is no card with this card number.Please give a valid card number");
             return(View("RegisterStudent"));
         }
     }
     else
     {
         ModelState.AddModelError("", "It seems it's lacking required information");
         return(View("RegisterStudent"));
     }
 }
Exemplo n.º 2
0
 public ActionResult AddCard(SearchStudent studentCardNumber)
 {
     if (ModelState.IsValid)
     {
         if (Session["StudentId"] != null)
         {
             CardDAO Card_DAO = new CardDAO();
             if (Card_DAO.ISExsistCardDate(studentCardNumber.CardNumber))
             {
                 RegestrationDAO Registrator = new RegestrationDAO();
                 if (Registrator.IsCardUnsoldAndUnRegisteredWhileRegitered(studentCardNumber.CardNumber))
                 {
                     int StudentId = (Int32)Session["StudentId"];
                     Registrator.UpdateCardsTableWithStudentId(studentCardNumber.CardNumber, StudentId);
                     ModelState.AddModelError("", "The New Card is added successfully .Please check student information by searching.");
                     return(View("SearchStudent"));
                 }
                 else
                 {
                     ModelState.AddModelError("", "The Card is already sold,Please give an unsold card number.");
                     return(View("SearchStudent"));
                 }
             }
             else
             {
                 ModelState.AddModelError("", "There is no card with this card number.Please give a valid card number.");
                 return(View("SearchStudent"));
             }
         }
         else
         {
             ModelState.AddModelError("", "Sorry Student information is not found.");
             return(View("SearchStudent"));
         }
     }
     else
     {
         ModelState.AddModelError("", "Sorry Student information is not found.");
         return(View("SearchStudent"));
     }
 }