Exemplo n.º 1
0
        static void Main(string[] args)
        {
            HttpApiClient client = new HttpApiClient(Host);

            IDataService service = client.CreateWebapi <IDataService>();

            DateTime dt = service.GetTime();

            Console.WriteLine($"get time:{dt}");

            string hello = service.Hello("henry");

            Console.WriteLine($"hello :{hello}");

            var orders = service.ListOrders(3, null);

            if (orders != null)
            {
                Console.WriteLine($"list orders: {orders.Count}");
            }

            orders = service.ListOrders();
            if (orders != null)
            {
                Console.WriteLine($"list orders: {orders.Count}");
            }

            var emp = service.GetEmployee(7);

            Console.WriteLine($"get employee id 7:{emp?.FirstName} {emp?.LastName}");

            emp = service.EditEmployee(5, new Employee {
                FirstName = "fan", LastName = "henry"
            });
            Console.WriteLine($"edit employee :{emp.EmployeeID} {emp?.FirstName} {emp?.LastName}");

            var count = service.AddEmployee(null);

            Console.WriteLine($"add employee :{count}");

            count = service.AddEmployee(new Employee {
                EmployeeID = 3
            }, new Employee {
                EmployeeID = 5
            });
            Console.WriteLine($"add employee :{count}");

            var login = service.Login("admin", "123456");

            Console.WriteLine($"login status:{login}");

            Console.Read();
        }