public ActionResult Create(CreateForm form) { if (ModelState.IsValid) { C.Department Department = new C.Department(form.Title, DateTime.Now, form.Description, SessionUser.GetUser().Id, true); int?DepId = DepartmentService.Create(Department, SessionUser.GetUser().Id); if (DepId != null) { if (DepartmentService.ChangeHeadOfDepartment((int)DepId, form.SelectedHeadOfDepartmentId, SessionUser.GetUser().Id)) { return(RedirectToAction("Index")); } } IEnumerable <C.Employee> Employees = EmployeeService.GetAllActive(); List <SelectListItem> HeadOfDepartmentCandidates = new List <SelectListItem>(); foreach (C.Employee emp in Employees) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")", Value = emp.Employee_Id.ToString() }); } form.HeadOfDepartmentCandidateList = HeadOfDepartmentCandidates; } return(View(form)); }
public CurrentOn(CD.Department department) { if (department != null) { Id = department.Id; Name = department.Name; } }
// GET: Admin/Department/Edit/5 public ActionResult Edit(int id) { C.Department Department = DepartmentService.GetDepartmentById(id); EditForm form = new EditForm { Id = (int)Department.Id, Title = Department.Title, Created = Department.Created, Description = Department.Description, Admin_Id = Department.Admin_Id, Admin = null, Active = Department.Active, }; IEnumerable <C.Employee> Employees = EmployeeService.GetAllActive(); List <SelectListItem> HeadOfDepartmentCandidates = new List <SelectListItem>(); foreach (C.Employee emp in Employees) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = emp.FirstName + " " + emp.LastName + " (" + emp.Email + ")", Value = emp.Employee_Id.ToString() }); } int?HeadOfDepId = DepartmentService.GetHeadOfDepartmentId(id); if (HeadOfDepId == null) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = "!!!NOT CHOSEN!!!", Value = 0.ToString() }); form.SelectedHeadOfDepartmentId = 0; } else { C.Employee HeadOfDepartment = EmployeeService.Get((int)HeadOfDepId); if (!Employees.Any(emp => emp.Employee_Id == HeadOfDepartment.Employee_Id)) { HeadOfDepartmentCandidates.Add(new SelectListItem() { Text = "!!!VIRÉ!!! " + HeadOfDepartment.FirstName + " " + HeadOfDepartment.LastName + " (" + HeadOfDepartment.Email + ")", Value = HeadOfDepartment.Employee_Id.ToString() }); } form.SelectedHeadOfDepartmentId = (int)HeadOfDepartment.Employee_Id; } form.HeadOfDepartmentCandidateList = HeadOfDepartmentCandidates; return(View(form)); }
internal static G.Department ToGlobal(this C.Department entity) { return(new G.Department() { Id = entity.Id, Title = entity.Title, Created = entity.Created, Description = entity.Description, Admin_Id = entity.Admin_Id, Active = entity.Active }); }
internal static G.Department ToGlobal(this C.Department departement) { if (departement == null) { return(null); } return(new G.Department() { Id = departement.Id, Name = departement.Name, Description = departement.Description, AdminId = departement.AdminId }); }
// GET: Admin/Department/Delete/5 public ActionResult Delete(int id) { C.Department Department = DepartmentService.GetDepartmentById(id); DeleteForm form = new DeleteForm { Id = (int)Department.Id, Title = Department.Title, Created = Department.Created, Description = Department.Description, Admin_Id = Department.Admin_Id, Admin = null }; return(View(form)); }
public EmployeeEditForm(C.Employee employee, C.Department currentDepartment, IEnumerable <C.Department> departmentList, bool isAdmin) { Id = employee.Id; FirstName = employee.FirstName; LastName = employee.LastName; Email = employee.Email; CurrentDepartmentId = currentDepartment != null ?currentDepartment.Id: 0; List <SelectListItem> listItems = new List <SelectListItem>(); foreach (C.Department department in departmentList) { listItems.Add(new SelectListItem { Value = department.Id.ToString(), Text = department.Name }); } DepartmentList = new SelectList(listItems, "Value", "Text"); SelectedItem = CurrentDepartmentId.ToString(); IsAdmin = isAdmin; }
public ActionResult Edit(int id, EditForm form) { if (ModelState.IsValid) { C.Department Department = new C.Department(form.Id, form.Title, DateTime.Now, form.Description, SessionUser.GetUser().Id, form.Active); try { if (DepartmentService.Edit(SessionUser.GetUser().Id, Department)) { DepartmentService.ChangeHeadOfDepartment(id, form.SelectedHeadOfDepartmentId, SessionUser.GetUser().Id); return(RedirectToAction("Index")); } } catch { return(View()); } return(RedirectToAction("Edit")); } return(View()); }
// GET: Admin/Department/Details/5 public ActionResult Details(int id) { C.Department Department = DepartmentService.GetDepartmentById(id); DetailsForm form = new DetailsForm { Id = (int)Department.Id, Title = Department.Title, Created = Department.Created, Description = Department.Description, Admin_Id = Department.Admin_Id, Admin = EmployeeService.Get(Department.Admin_Id), Active = Department.Active, Employees = DepartmentService.GetEmployeesForDepartment(id) }; int?HeadOfDepartmentId = DepartmentService.GetHeadOfDepartmentId(id); if (HeadOfDepartmentId != null) { form.HeadOfDepartment = EmployeeService.Get((int)HeadOfDepartmentId); } return(View(form)); }
// GET: Admin/Employee/Edit/5 public ActionResult Edit(int id) { EmployeeService repoEmp = new EmployeeService(); AdminService repoAdmin = new AdminService(); DepartmentService repoDepart = new DepartmentService(); C.Employee employee = repoEmp.Get(id);/* * C.Admin a = null; * if (repoAdmin.IsAdminByEmployeeId(id)) * { * a = repoAdmin.GetByEmployeeId(id); * } * else * { * a = new C.Admin(, e); * }*/ C.Department currentDepart = repoDepart.GetByEmployeeId(employee.Id); IEnumerable <C.Department> departmentList = repoDepart.Get(); EmployeeEditForm profil = new EmployeeEditForm(employee, currentDepart, departmentList, repoAdmin.IsAdminByEmployeeId(id)); return(View(profil)); }
// GET: Employee/Department/Details/5 public ActionResult Details(int id) { C.Department Department = DepartmentService.GetDepartmentById(id); DetailsForm form = new DetailsForm { Id = (int)Department.Id, Title = Department.Title, Created = Department.Created, Description = Department.Description, Creator = EmployeeService.Get(Department.Admin_Id), Active = Department.Active, Employees = DepartmentService.GetEmployeesForDepartment((int)Department.Id), Documents = DocumentService.GetForDepartment((int)Department.Id).Select(d => new Doc.ListForm { Name = d.Filename, Id = (int)d.Id }) }; int?HeadOfDepartmentId = DepartmentService.GetHeadOfDepartmentId((int)Department.Id); if (HeadOfDepartmentId != null) { form.HeadOfDepartment = EmployeeService.Get((int)HeadOfDepartmentId); } return(View(form)); }
public EmployeeEditForm(C.Admin admin, C.Department currentDepartment, IEnumerable <C.Department> departmentList) : this(admin, currentDepartment, departmentList, admin.IsAdmin) { }