// GET: Employee/Edit/5 public IActionResult Edit(int?id) { try { if (id == null) { return(NotFound()); } EmployeeViewModel employeeViewModel = _IEmployee.GetEmployeeViewModel((int)id); if (employeeViewModel == null) { return(NotFound()); } ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IEmployee.GetSubCompanies()); ViewBag.Positions = UtilityService.CreatePositionListItemn(_IEmployee.GetPositions()); return(View(employeeViewModel)); } catch (Exception ex) { Console.WriteLine("Message " + ex.Message); ViewBag.subCompany = new SelectList(_IEmployee.GetSubCompaniesQuery()); ViewBag.position = new SelectList(_IEmployee.GetPositionsQuery()); return(View(nameof(Index))); } }
public IActionResult Create([Bind("EmployeeName,ProjectName,Salary,SubCompanyId,PositionId,Joined_Date,_Address,_PhoneNumber,Addresses,PhoneNumbers")] EmployeeViewModel employeeViewModel) { if (ModelState.IsValid) { if (_IEmployee.CreateEmployee(employeeViewModel)) { return(RedirectToAction(nameof(Index))); } else { ViewBag.Message = "Unable To Create"; } } ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IEmployee.GetSubCompanies()); ViewBag.Positions = UtilityService.CreatePositionListItemn(_IEmployee.GetPositions()); if (employeeViewModel.Addresses == null) { employeeViewModel.Addresses = new List <string>(); } if (employeeViewModel.PhoneNumbers == null) { employeeViewModel.PhoneNumbers = new List <string>(); } return(View(employeeViewModel)); }
public IActionResult Edit(int id, [Bind("Id,EmployeeName,Salary,SubCompanyId,PositionId,Joined_Date,Addresses,_Address,_PhoneNumber,PhoneNumbers")] EmployeeViewModel employeeViewModel) { if (id != employeeViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { if (_IEmployee.Update(employeeViewModel)) { return(RedirectToAction(nameof(Index))); } else { ViewBag.Message = "Unable To Update."; } } ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IEmployee.GetSubCompanies()); ViewBag.Positions = UtilityService.CreatePositionListItemn(_IEmployee.GetPositions()); return(View(employeeViewModel)); }
public IActionResult Create() { ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IEmployee.GetSubCompanies()); ViewBag.Positions = UtilityService.CreatePositionListItemn(_IEmployee.GetPositions()); EmployeeViewModel employeeViewModel = new EmployeeViewModel(); employeeViewModel.Addresses = new List <string>(); employeeViewModel.PhoneNumbers = new List <string>(); return(View(employeeViewModel)); }
public IActionResult Create([Bind("ProjectName,SubCompanyId")] ProjectViewModel projectViewModel) { if (ModelState.IsValid) { if (_IProject.Create(projectViewModel)) { return(RedirectToAction(nameof(Index))); } else { ViewBag.Message = "Unable To create."; } } ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IProject.GetSubCompanies()); return(View(projectViewModel)); }
// GET: Project/Edit/5 public IActionResult Edit(int?id) { if (id == null) { return(NotFound()); } ProjectViewModel projectViewModel = _IProject.GetProjectViewModel((int)id); if (projectViewModel == null) { return(NotFound()); } ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IProject.GetSubCompanies()); return(View(projectViewModel)); }
public IActionResult Edit(int id, [Bind("Id,ProjectName,SubCompanyId")] ProjectViewModel projectViewModel) { if (id != projectViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { if (_IProject.Update(projectViewModel)) { return(RedirectToAction("Index")); } else { ViewBag.Message = "Unable To Update."; } } ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IProject.GetSubCompanies()); return(View(projectViewModel)); }
public IActionResult Create() { ViewBag.SubCompanies = UtilityService.CreateSubCompanyListItem(_IProject.GetSubCompanies()); return(View()); }