Ejemplo n.º 1
0
        public void RetrieveEmployeeByIdTest()
        {
            int    id   = 2;
            string name = "b";

            createClient.CreateEmployee(id, name);

            Employee e = retrieveClient.SearchById(2);

            Assert.AreEqual(2, e.Id);
        }
Ejemplo n.º 2
0
        public void serachByIdTest()
        {
            _employee.Name = "Priti";
            _employee      = _writeClient.CreateEmployee(_employee);

            _remarkObject._remark     = "Hello Priti";
            _remarkObject._remarkTime = DateTime.Now;
            _employee.Remarks.Add(_remarkObject);

            Employee e = _readClient.SearchById(_employee.Id);

            Assert.AreEqual(_employee.Id, e.Id);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var client         = new CreateEmployeeServiceClient("BasicHttpBinding_ICreateEmployeeService");
            var retrieveClient = new RetrieveEmployeeServiceClient("WSHttpBinding_IRetrieveEmployeeService");

            Console.WriteLine("1 Add Employee\n2 Add remarks\n3 Get Employee Details by id\n4 Get Employee Details by Name\n5 Get All Employees Details\nEnter Your Choice: ");
            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case 1:
                Console.WriteLine("Enter Employee Id: ");
                int id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter Employee Name: ");
                String name = Console.ReadLine();
                Console.WriteLine("Enter Employee RemarkText: ");
                //String remarkText =Console.ReadLine();
                Employee e = new Employee(id, name, System.DateTime.Now, Console.ReadLine());
                Console.WriteLine(client.CreateEmployee(e));
                break;

            case 2:
                Console.WriteLine("Enter the id: ");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter the Remark: ");
                Console.WriteLine(client.AddRemarks(id, Console.ReadLine()));
                break;

            case 3:
                Console.WriteLine("Enter the id: ");
                id = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine(retrieveClient.SearchById(id));
                break;

            case 4:
                Console.WriteLine("Enter the Name: ");
                Console.WriteLine(retrieveClient.SearchByName(Console.ReadLine()));
                break;

            case 5:
                List <Employee> list = new List <Employee>();
                list.AddRange(retrieveClient.GetEmployees());
                foreach (var item in list)
                {
                    Console.WriteLine(item.Id + item.Name);
                }
            }

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            var client         = new CreateEmployeeServiceClient("BasicHttpBinding_ICreateEmployeeService");
            var retrieveClient = new RetrieveEmployeeServiceClient("WSHttpBinding_IRetrieveEmployeeService");
            int choice         = 0;

            do
            {
                Console.WriteLine("\nEmployee Management Service");
                Console.WriteLine("1.Add new Employee\n2.Add Remarks\n3.Search Employee by Id\n4.Search Employee by Name\n5.Get All Employee Details\n6.Exit");
                Console.WriteLine("Enter your choice : ");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    Console.WriteLine("Enter Employee Name : ");
                    string   name        = Console.ReadLine();
                    Employee newEmployee = new Employee();
                    newEmployee.Name = name;
                    newEmployee      = client.CreateEmployee(newEmployee);
                    Console.WriteLine("Employee created with Id : {0}", newEmployee.Id);
                    break;

                case 2:
                    Console.WriteLine("Enter Employee ID : ");
                    string id = Console.ReadLine();
                    Console.WriteLine("Enter the Remark : ");
                    string remark = Console.ReadLine();
                    string status = client.AddRemarks(new Guid(id), remark);
                    Console.WriteLine(status);
                    break;

                case 3:
                    Console.WriteLine("Enter Employee ID : ");
                    id = Console.ReadLine();
                    Employee employee = retrieveClient.SearchById(new Guid(id));
                    Console.WriteLine("ID : " + employee.Id + "\nName : " + employee.Name);
                    Console.WriteLine("Posted on\tRemark");
                    foreach (var r in employee.Remarks)
                    {
                        Console.WriteLine(r._remarkTime + "\t" + r._remark);
                    }
                    break;

                case 4:
                    Console.WriteLine("Enter Employee Name : ");
                    name     = Console.ReadLine();
                    employee = retrieveClient.SearchByName(name);
                    Console.WriteLine("ID : " + employee.Id + "\nName : " + employee.Name);
                    Console.WriteLine("Posted on\tRemark");
                    foreach (var r in employee.Remarks)
                    {
                        Console.WriteLine(r._remarkTime + "\t" + r._remark);
                    }

                    break;

                case 5:
                    Console.WriteLine("Employee Data");
                    List <Employee> empData = new List <Employee>();
                    empData.AddRange(retrieveClient.GetAllEmployees());
                    foreach (Employee emp in empData)
                    {
                        Console.WriteLine("ID : " + emp.Id + "\nName : " + emp.Name);
                        Console.WriteLine("Posted on\tRemark");
                        if (emp.Remarks != null)
                        {
                            foreach (var r in emp.Remarks)
                            {
                                Console.WriteLine(r._remarkTime + "\t" + r._remark);
                            }
                        }
                    }
                    break;

                case 6:
                    break;

                default:
                    Console.WriteLine("Invalid Choice");
                    break;
                }
            } while (choice != 6);
            //var employeeObject = new EmployeeWcf.EmployeeService();
        }