public OperatorEditVM(Oper oper, List <Shift> shift, List <Certification> certification, OperatorCertifications operatorCertifications) { Oper = oper; Shift = shift; Certification = certification; OperatorCertifications = operatorCertifications; }
//Add Certification to Operator public IActionResult AddCertToOper(Oper oper, OperatorCertifications operatorCertifications) { var newOperatorCertifications = new OperatorCertifications(); newOperatorCertifications.OperatorId = oper.OperatorId; newOperatorCertifications.CertificationId = operatorCertifications.CertificationId; db.OperatorCertifications.Add(newOperatorCertifications); db.SaveChanges(); return(RedirectToAction("Index")); }
//Edit Operator GET public IActionResult Edit(int id) { var thisOperator = db.Operators.FirstOrDefault(x => x.OperatorId == id); List <Shift> shifts = db.Shifts.ToList(); List <Certification> certifications = db.Certifications.ToList(); OperatorCertifications operatorCertifications = new OperatorCertifications(); OperatorEditVM VM = new OperatorEditVM(thisOperator, shifts, certifications, operatorCertifications); return(View(VM)); }