Esempio n. 1
0
        public async Task <Models.Employee> SaveAsync(Models.Employee employee)
        {
            var request = new ProtocolBuffers.EmployeeRequest
            {
                Employee = _employeeConverter.ToMessage(employee)
            };

            var response = await _employeeServiceClient.SaveAsync(request);

            return(_employeeConverter.ToModel(response.Employee));
        }
Esempio n. 2
0
        static async Task Save(EmployeeService.EmployeeServiceClient client)
        {
            var response = await client.SaveAsync(new EmployeeRequest {
                Employee = new Employee
                {
                    Id        = 9,
                    No        = 1009,
                    FirstName = "ye3",
                    LastName  = "feng4",
                    Salary    = 2033,
                    Status    = Grpc.Server.Protos.EmployeeStatus.Retired
                }
            });

            Console.WriteLine(response);
        }
Esempio n. 3
0
        public static async Task SaveAsync(EmployeeService.EmployeeServiceClient client)
        {
            Employee employee = new Employee
            {
                No        = 888,
                FirstName = "KKK",
                LastName  = "V"
            };

            var call = await client.SaveAsync(new EmployeeRequest
            {
                Employee = employee
            });

            Console.WriteLine($"response: {call}");
        }
Esempio n. 4
0
        public static async Task SaveAsync(EmployeeService.EmployeeServiceClient client)
        {
            try
            {
                if (!NeedToken() || await GetTokenAsync(client))
                {
                    var headers = new Metadata
                    {
                        { "Authorization", $"Bearer {_token}" }
                    };

                    var response = await client.SaveAsync(new EmployeeRequest
                    {
                        Employee = new Employee
                        {
                            No        = 1314011524,
                            FirstName = "Christopher",
                            LastName  = "Shi",
                            //Salary = 10000
                            MonthSalary = new MonthSalary
                            {
                                Basic = 4000f,
                                Bonus = 345.5f
                            },
                            Status     = EmloyeeStatus.Normal,
                            LastModify = Timestamp.FromDateTime(DateTime.UtcNow)
                        }
                    }, headers);

                    Console.WriteLine($"Response messages: { response }");
                }
            }
            catch (RpcException e)
            {
                Log.Logger.Error($"{JsonConvert.SerializeObject(e.Trailers)}");
                Log.Logger.Error(e.Message);
            }
        }