// // GET: /Employee/Delete/5 public ActionResult Delete(int id) { using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal { client.DeleteEmployee(id); } return RedirectToAction("Index"); }
// // GET: /Employee/Edit/5 public ActionResult Edit(int id) { using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal { var c = client.GetEmployee(id); if (c != null) return View(client.GetEmployee(id)); else return View(); } }
/// <summary> /// Return the employees. /// </summary> /// <returns></returns> public ActionResult Employees() { // Create Employee view data EmployeeViewData viewData = CreateViewData<EmployeeViewData>(); // Populate view data EmployeeServiceContractClient contractClient = new EmployeeServiceContractClient(); Employees empList = contractClient.GetEmployees(); viewData.Employees = empList.ToList(); //BL.Controllers.EmployeeController employeeController = new BL.Controllers.EmployeeController(); //viewData.Employees = employeeController.Employees().ToList(); return View("Employees", viewData); }
/// <summary> /// Return the employees. /// </summary> /// <returns></returns> public ActionResult Employees() { // Create Employee view data EmployeeViewData viewData = CreateViewData <EmployeeViewData>(); // Populate view data EmployeeServiceContractClient contractClient = new EmployeeServiceContractClient(); Employees empList = contractClient.GetEmployees(); viewData.Employees = empList.ToList(); //BL.Controllers.EmployeeController employeeController = new BL.Controllers.EmployeeController(); //viewData.Employees = employeeController.Employees().ToList(); return(View("Employees", viewData)); }
public ActionResult Create(Employee employee) { try { // TODO: Add insert logic here using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal { //give it some defaults not in UI, can't sukkel with dates and stuff now employee.TerminationDate= new DateTime(1900,1,1); employee.TerminationDate = new DateTime(1900, 1, 1); TransactionResponse response =client.AddEmployee(employee); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(Employee employee) { try { using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal { employee.TerminationDate = new DateTime(1900, 1, 1); employee.EmployedDate = new DateTime(1900, 1, 1); TransactionResponse response =client.UpdateEmployee(employee); } return RedirectToAction("Index"); } catch { return View(); } }
// // GET: /Employee/ public ActionResult Index() { using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal { return View(client.GetAllEmloyees()); } }
public void TestWCFServiceAddEmployee() { using (EmployeeServiceContractClient client = new EmployeeServiceContractClient()) { var response = client.AddEmployee(new Employee(){EmployedDate = DateTime.Now, FirstName = "WCF", LastName = "Services TEst", BirthDate= new DateTime(1950,1,1), EmployeeNum = Guid.NewGuid().ToString("N").Substring(0,15), TerminationDate = new DateTime(1911,1,1) }); foreach (OperationError error in response.Status.Errors) { Console.WriteLine(error.Reason); } Console.WriteLine(response.Status.Success); } }