Ejemplo n.º 1
0
 //
 // GET: /Employee/Delete/5
 public ActionResult Delete(int id)
 {
     using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal
     {
         client.DeleteEmployee(id);
     }
     return RedirectToAction("Index");
 }
Ejemplo n.º 2
0
 //
 // 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();
     }
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
        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();
            }
        }
Ejemplo n.º 6
0
        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();
            }
        }
Ejemplo n.º 7
0
 //
 // GET: /Employee/
 public ActionResult Index()
 {
     using (wcfEmployeeService.EmployeeServiceContractClient client = new EmployeeServiceContractClient()) //automatic disposal
     {
         return View(client.GetAllEmloyees());
     }
 }
Ejemplo n.º 8
0
 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);
     }
 }