Esempio n. 1
0
        public static void Run(string patternName)
        {
            IDesignPatternClient client     = RetrieveClient(patternName)();
            HeaderText           headerText = new HeaderText('-', client.Name)
                                              .RunInBetween(client.Main);

            headerText.Write();

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
Esempio n. 2
0
        private static bool IsEmployeePresent(int id)
        {
            Employee       emp     = new Employee();
            RetrieveClient rclient = new RetrieveClient();

            emp = rclient.SearchById(id);
            if (emp != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            CreateEmployeeAndAddRemarksClient client = new CreateEmployeeAndAddRemarksClient();
            RetrieveClient rclient = new RetrieveClient();
            int            id, choice = 0;
            String         name;
            Employee       emp = new Employee();

            do
            {
                Console.WriteLine("1. Add Employee Record");
                Console.WriteLine("2. Search Employee Details By ID");
                Console.WriteLine("3. Search Employee Details By Name");
                Console.WriteLine("4. Add Remark");
                Console.WriteLine("5. Get the list of all Employees");
                Console.WriteLine("0. Exit");
                Console.WriteLine("Choose your operation:");
                choice = int.Parse(Console.ReadLine());
                Console.WriteLine("\n\n");
                switch (choice)
                {
                case 1:
                    do
                    {
                        Console.WriteLine("EmployeeID : ");
                        id = int.Parse(Console.ReadLine());
                        if (IsEmployeePresent(id))
                        {
                            Console.WriteLine("Employee Name : ");
                            name = Console.ReadLine();
                            client.CreateNewEmployee(id, name);
                            break;
                        }
                    } while (true);
                    break;

                case 2:
                    Console.WriteLine("Enter the Employee-ID : ");
                    id = int.Parse(Console.ReadLine());
                    var r = rclient.SearchById(id);
                    Console.WriteLine(r.Id);
                    Console.WriteLine(r.Name + "\n");
                    break;

                case 3:
                    Console.WriteLine("Enter the Employee-Name : ");
                    //name = Console.ReadLine();
                    //emp = rclient.SearchByName(name);
                    //Console.WriteLine(emp.Id);
                    //Console.WriteLine(emp.Name+"\n");
                    break;

                case 4:
                    Console.WriteLine("Enter the Employee-ID : ");
                    id = int.Parse(Console.ReadLine());
                    Employee employee = rclient.SearchById(id);
                    //try
                    //{
                    //    Employee employee = rclient.SearchById(id);

                    //    Console.WriteLine("Add the remark");
                    //    string text = Console.ReadLine();
                    //    client.AddRemarks(id, text);
                    //}
                    //catch (FaultException e)
                    //{
                    //     if (e.Code.Name == "101")
                    //      {
                    //        Console.WriteLine("{0}",e.Reason);
                    //      }
                    //}

                    break;

                case 5:
                    //var list = rclient.GetAllEmployeeList();
                    //foreach (Employee e in list)
                    //{
                    //    Console.WriteLine("Employee Id :"+e.Id);
                    //    Console.WriteLine("Employee Name :"+e.Name);
                    //    if (e.remarkObject != null)
                    //    {
                    //        Console.WriteLine("Remark :" + e.remarkObject.Remark);
                    //        Console.WriteLine("Date :" + e.remarkObject.Date);
                    //    }
                    //    Console.WriteLine("\n");
                    //}
                    break;
                }
            }while(choice != 0);
        }
Esempio n. 4
0
        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);
        }