Esempio n. 1
0
 public ActionResult Create([Bind(Include = "TE_Name,TE_Age,TE_DOB,TE_Education,TE_MainLang,TE_TOEIC,EnrollmentDate")] Trainee trainee)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Trainees.Add(trainee);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException /* dex */)
     {
         //Log the error (uncomment dex variable name and add a line here to write a log.
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(trainee));
 }
Esempio n. 2
0
 public static void Initialize(ITSContext context)
 {
     context.Database.EnsureCreated();
     if (context.Curso.Any())
     {
         return;
     }
     {
         var Curso = new Curso[]
         {
             new Curso {
                 id_curso = 01, nombre_curso = "Programacion", nivel = "XV"
             }
         };
         foreach (Curso a in Curso)
         {
             context.Curso.Add(a);
         }
         context.SaveChanges();
     }
 }