public EmployeeInExternalTrainingVM(EmployeeInExternalTraining empInTraining) { EmployeeInTraining = empInTraining; bool BudgetAlert = false; bool TrainingNumberAlert = false; if (empInTraining.TrainingStatus == EmployeeInExternalTraining.TrainingStatuses.ממתין) { if (empInTraining.Employee.RemainingBudget < empInTraining.Training.Cost) { BudgetAlert = true; } if (empInTraining.Employee.RemainingTrainings <= 0) { TrainingNumberAlert = true; } } if (BudgetAlert && TrainingNumberAlert) { Alert = "ההדרכה תגרום לחריגה בתקציב ההדרכות ובחריגה בכמות ההדרכות השנתית לעובד"; } else if (BudgetAlert) { Alert = "ההדרכה תגרום לחריגה בתקציב ההדרכות השנתי לעובד"; } else if (TrainingNumberAlert) { Alert = "ההדרכה תגרום לחריגה בכמות ההדרכות השנתית לעובד"; } }
public ActionResult DeleteConfirmed(int id) { EmployeeInExternalTraining employeeInTraining = db.EmployeeInExternalTrainings.Find(id); db.EmployeeInExternalTrainings.Remove(employeeInTraining); db.SaveChanges(); return(RedirectToAction("EmployeesInExternalTraining", new { id = employeeInTraining.ExternalTrainingID })); }
// GET: EmployeeInTraining/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeInExternalTraining employeeInTraining = db.EmployeeInExternalTrainings.Find(id); if (employeeInTraining == null) { return(HttpNotFound()); } ViewBag.id = id; return(View(employeeInTraining)); }
public ActionResult Create([Bind(Include = "EmployeeInExternalTrainingsID,ExternalTrainingID")] EmployeeInExternalTraining employeeInTraining, int[] EmployeeIDs) { if (ModelState.IsValid) { foreach (var id in EmployeeIDs) { EmployeeInExternalTraining emp = new EmployeeInExternalTraining(); emp.ExternalTrainingID = employeeInTraining.ExternalTrainingID; emp.EmployeeID = id; db.EmployeeInExternalTrainings.Add(emp); db.SaveChanges(); } } return(RedirectToAction("EmployeesInExternalTraining", new { id = employeeInTraining.ExternalTrainingID })); }
// GET: EmployeeInExternalTraining/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeInExternalTraining employeeInTraining = db.EmployeeInExternalTrainings.Find(id); if (employeeInTraining == null) { return(HttpNotFound()); } ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName", employeeInTraining.EmployeeID); ViewBag.ExternalTrainingID = new SelectList(db.ExternalTrainings, "ExternalTrainingID", "Name", employeeInTraining.ExternalTrainingID); ViewBag.id = id; return(View(employeeInTraining)); }
public ActionResult Edit(EmployeeInExternalTraining employeeInTraining) { if (ModelState.IsValid) { if (employeeInTraining.TrainingStatus == EmployeeInExternalTraining.TrainingStatuses.אושר) { var employee = db.Employees.Find(employeeInTraining.EmployeeID); var training = db.ExternalTrainings.Find(employeeInTraining.ExternalTrainingID); employee.RemainingBudget -= Convert.ToInt32(training.Cost.Value); employee.RemainingTrainings -= 1; db.Entry(employee).State = EntityState.Modified; } db.Entry(employeeInTraining).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("EmployeesInExternalTraining", new { id = employeeInTraining.ExternalTrainingID })); } ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "LastName", employeeInTraining.EmployeeID); ViewBag.ExternalTrainingID = new SelectList(db.ExternalTrainings, "ExternalTrainingID", "Name", employeeInTraining.ExternalTrainingID); return(View(employeeInTraining)); }