public void RetrieveEmployees() { employee.Id = Int32.Parse(testContextInstance.DataRow["EmployeeId"].ToString()); employee.Name = testContextInstance.DataRow["EmployeeName"].ToString(); employee.RemarkText = testContextInstance.DataRow["EmployeeRemark"].ToString(); employee.RemarkDate = Convert.ToDateTime(testContextInstance.DataRow["EmployeeRemarkDate"].ToString()); employeeCreateObject.CreateEmployee(employee); List <Employee> employeeList = new List <Employee>(); employeeList.AddRange(employeeRetrieveObject.GetAllEmployees()); }
static void Main(string[] args) { var employeeCreateObject = new AddandCreateClient("BasicHttpBinding_IAddandCreate"); var employeeRetrieveObject = new RetrieveClient("WSHttpBinding_IRetrieve"); int option = 0; try { do { Console.WriteLine("1.Create Employee"); Console.WriteLine("2.Retrive All Employees"); Console.WriteLine("3.Retrive Employees by Id"); Console.WriteLine("4.Retrive Employees by Name"); Console.WriteLine("5.Update Employee's Remark"); Console.WriteLine("6.Retrive Employees by Remark"); Console.WriteLine("Enter your option"); option = Convert.ToInt32(Console.ReadLine()); switch (option) { case 1: string ans = ""; do { Console.WriteLine("Enter Employee Id "); int id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Employee Name "); string name = Console.ReadLine(); Console.WriteLine("Enter Employee Remark Date"); DateTime date = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("Enter Employee Remark Text"); string text = Console.ReadLine(); var employee = new Employee(); employee.Id = id; employee.Name = name; employee.RemarkDate = date; employee.RemarkText = text; employeeCreateObject.CreateEmployee(employee); Console.WriteLine("Want to continue(y/n)"); ans = Console.ReadLine(); } while (ans != "n"); break; case 2: List <Employee> empList = new List <Employee>(); empList.AddRange(employeeRetrieveObject.GetAllEmployees()); foreach (Employee employee in empList) { Console.WriteLine("Employee Id : " + employee.Id); Console.WriteLine("Employee Name : " + employee.Name); Console.WriteLine("Employee Date : " + employee.RemarkDate); Console.WriteLine("Employee Remark : " + employee.RemarkText); Console.WriteLine("\n"); } break; case 3: Console.WriteLine("Enter the Search Id"); int searchId = Convert.ToInt32(Console.ReadLine()); var idDetails = employeeRetrieveObject.SearchById(searchId); Console.WriteLine("Employee Id : " + idDetails.Id); Console.WriteLine("Employee Name : " + idDetails.Name); Console.WriteLine("Employee Date : " + idDetails.RemarkDate); Console.WriteLine("Employee Remark : " + idDetails.RemarkText); Console.WriteLine("\n"); break; case 4: Console.WriteLine("Enter the Search Name"); string empName = Console.ReadLine(); List <Employee> empListByName = new List <Employee>(); empListByName.AddRange(employeeRetrieveObject.SearchByName(empName)); foreach (Employee employee in empListByName) { Console.WriteLine("Employee Id : " + employee.Id); Console.WriteLine("Employee Name : " + employee.Name); Console.WriteLine("Employee Date : " + employee.RemarkDate); Console.WriteLine("Employee Remark : " + employee.RemarkText); Console.WriteLine("\n"); } break; case 5: Console.WriteLine("Enter Id whose remark you want update"); int empId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Add New Remark"); string remark = Console.ReadLine(); employeeCreateObject.AddRemarksById(empId, remark); break; case 6: Console.WriteLine("Enter the Search Remark"); string searchRemark = Console.ReadLine(); List <Employee> empListByRemarkName = new List <Employee>(); empListByRemarkName.AddRange(employeeRetrieveObject.GetAllEmployeesHavingRemark(searchRemark)); foreach (Employee employee in empListByRemarkName) { Console.WriteLine("Employee Id : " + employee.Id); Console.WriteLine("Employee Name : " + employee.Name); Console.WriteLine("Employee Date : " + employee.RemarkDate); Console.WriteLine("Employee Remark : " + employee.RemarkText); Console.WriteLine("\n"); } break; } } while (option != 7); } catch (FaultException <FaultExceptionContract> ex) { string message = "StatusCode: " + ex.Detail.StatusCode; message += "\nMessage: " + ex.Detail.Message; Console.WriteLine(message); } }
static void Main(string[] args) { string name, remark, result; int choice, id = 0; var createObj = new AddandCreateClient("BasicHttpBinding_IAddandCreate"); var retrieveObj = new RetrieveClient("WSHttpBinding_IRetrieve"); DateTime today = DateTime.Today; do { Console.WriteLine("\n--------------------------------------------------"); Console.WriteLine("\n\n1.Add Employee Details."); Console.WriteLine("2.Get Details Of All Employees."); Console.WriteLine("3.Search Employee Details by Id."); Console.WriteLine("4.Search Employee Details by Name."); Console.WriteLine("5.Add Remark To An Employee."); Console.WriteLine("6.Exit."); Console.WriteLine("Enter your Choice:"); choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("Enter Name Of Employee:"); name = Console.ReadLine(); Console.WriteLine("Enter Remark for Employee:"); remark = Console.ReadLine(); createObj.CreateEmployee(name, remark, today); break; case 2: var returnedList = retrieveObj.GetAllEmployees(); for (int i = 0; i < returnedList.Length; i++) { Console.WriteLine("\n\n\n"); Console.WriteLine("Id:" + returnedList[i].Id); Console.WriteLine("Name:" + returnedList[i].Name); Console.WriteLine("Date:" + returnedList[i].date); Console.WriteLine("Remark:" + returnedList[i].remark + "\n\n"); } break; case 3: Console.WriteLine("Enter Id Of Employee:"); id = Convert.ToInt32(Console.ReadLine()); result = retrieveObj.SearchById(id); Console.WriteLine(result + "\n\n"); break; case 4: Console.WriteLine("Enter Name Of Employee:"); name = Console.ReadLine(); result = retrieveObj.SearchByName(name); Console.WriteLine(result + "\n\n"); break; case 5: Console.WriteLine("Enter Id Of Employee:"); id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Remark For Employee:"); remark = Console.ReadLine(); result = createObj.AddRemarksToEmployee(id, remark); //result = createObj.; Console.WriteLine(result + "\n\n"); break; case 6: System.Environment.Exit(1); break; default: Console.WriteLine("\n\nInvalid Choice."); break; } } while (choice != 6); }