public ActionResult Create([Bind(Include = "TraineeID,TraineeName,TraineeAddress,TraineeAge,DOB,MProgramL,TOEIC,Experience")] Trainee trainee)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Trainees.Add(trainee);
                    db.SaveChanges();

                    AuthenController.CreateAccount("Tnee" + trainee.TraineeID, "trainee", "Trainee");
                    return(RedirectToAction("Index"));
                }catch (Exception ex)
                {
                    ModelState.AddModelError("", "ID is already existed! ");
                    return(View(trainee));
                }
            }

            return(View(trainee));
        }
Esempio n. 2
0
      public ActionResult Create([Bind(Include = "TStaffID,TStaffName,TStaffAddress,TStaffPhone,TStaffEmail")] TrainingStaff trainingStaff)
      {
          if (ModelState.IsValid)
          {
              try
              {
                  db.TrainingStaffs.Add(trainingStaff);
                  db.SaveChanges();

                  AuthenController.CreateAccount("TningStaff" + trainingStaff.TStaffID, "trainingstaff", "TrainingStaff");
                  return(RedirectToAction("Index"));
              }catch (Exception ex)
              {
                  ModelState.AddModelError("", "ID is already existed! ");
                  return(View(trainingStaff));
              }
          }

          return(View(trainingStaff));
      }
        public ActionResult Create([Bind(Include = "TrainerID,TrainerName,TrainerWorkingPlace,TrainerPhone,TrainerEmail")] Trainer trainer)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Trainers.Add(trainer);
                    db.SaveChanges();

                    AuthenController.CreateAccount("Tner" + trainer.TrainerID, "trainer", "Trainer");
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "ID is already existed! ");
                    return(View(trainer));
                }
            }

            return(View(trainer));
        }