コード例 #1
0
        public async Task AddVacation([FromBody] VacationRequestDto vacationRequestDto)
        {
            CreateVacation command = new CreateVacation(vacationRequestDto.EmployeeId,
                                                        new Vacation.Contract.Vacation.ValueObject.VacationInfo()
            {
                EmployeeId = vacationRequestDto.EmployeeId,
                Start      = vacationRequestDto.StartDate,
                End        = vacationRequestDto.EndDate,
                Status     = Vacation.Contract.Vacation.ValueObject.Status.Pending
            });

            await _commandBus.Send(command);
        }
コード例 #2
0
        void WriteToMongoDb(VacationCreated vacationCreated)
        {
            // Create a New HttpClient object.
            HttpClient client = new HttpClient();

            CreateVacation createVacation = new CreateVacation(vacationCreated.Data.EmployeeId, vacationCreated.Data);

            // Call asynchronous network methods in a try/catch block to handle exceptions
            try
            {
                client.PostAsync("http://v1/api/vacationHandler/Vacation", new JsonContent(createVacation)).Wait();
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine("\nException Caught!");
                Console.WriteLine("Message :{0} ", e.Message);
            }

            // Need to call dispose on the HttpClient object
            // when done using it, so the app doesn't leak resources
            client.Dispose();
        }