Esempio n. 1
0
        // GET: GO_Training/Create
        public async Task <IActionResult> Create()
        {
            var employee = await EmployeeController.GetEmployeeModelList();

            var courses = await _context.Course.ToListAsync();

            var model = new GO_TrainingEditModel {
                Courses   = courses,
                Employees = employee
            };

            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,Employee,Course,Year_taken")] GO_TrainingEditModel Training)
        {
            var training = new GO_Training {
                Id         = Training.Id,
                Employee   = Training.Employee,
                Course     = Training.Course,
                Year_taken = Training.Year_taken
            };

            if (ModelState.IsValid)
            {
                _context.Add(training);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(training));
        }
Esempio n. 3
0
        // GET: GO_Training/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var employee = await EmployeeController.GetEmployeeModelList();

            var courses = await _context.Course.ToListAsync();

            var gO_Training = await(from gt in _context.GO_Training
                                    join c in _context.Course on gt.Course equals c.Id
                                    join e in _context.Employee on gt.Employee equals e.Id
                                    where gt.Id == id
                                    select new GO_TrainingModel {
                Id           = gt.Id,
                Course       = gt.Course,
                Employee     = gt.Employee,
                CourseName   = c.Name,
                EmployeeName = e.First_name + " " + e.Last_name,
                Year_taken   = gt.Year_taken
            }).FirstOrDefaultAsync();

            var gO_Training2 = await _context.GO_Training.FindAsync(id);

            var model = new GO_TrainingEditModel {
                Id           = gO_Training.Id,
                Employees    = employee,
                Courses      = courses,
                Year_taken   = gO_Training.Year_taken,
                Employee     = gO_Training.Employee,
                Course       = gO_Training.Course,
                CourseName   = gO_Training.CourseName,
                EmployeeName = gO_Training.EmployeeName
            };

            if (gO_Training == null)
            {
                return(NotFound());
            }

            return(View(model));
        }