Ejemplo n.º 1
0
        private async Task <CalendarEvent> CompleteVacation(CalendarEvent @event, string completeBy, DateTimeOffset timestamp)
        {
            var approvedStatus = new CalendarEventStatuses().ApprovedForType(@event.Type);
            var newEvent       = new CalendarEvent(
                @event.EventId,
                @event.Type,
                @event.Dates,
                approvedStatus,
                @event.EmployeeId
                );

            var updateMessage   = new UpdateVacation(newEvent, @event, completeBy, timestamp);
            var updatedVacation = await this.UpdateVacation(updateMessage, false);

            return(updatedVacation);
        }
Ejemplo n.º 2
0
        private async Task <CalendarEvent> UpdateVacation(UpdateVacation message, bool needCheckUpdateAvailable = true)
        {
            // When vacation is changed from internal code (change to Approved when all approvals granted), availability should not be checked
            if (needCheckUpdateAvailable)
            {
                await this.EnsureUpdateAvailable(message.NewEvent, message.OldEvent);
            }

            var response = await this.vacationsRegistry.Ask <UpdateVacation.Response>(message);

            switch (response)
            {
            case UpdateVacation.Success success:
                return(success.NewEvent);

            case UpdateVacation.Error error:
                throw new Exception("Error occured on vacation update", error.Exception);

            default:
                throw new Exception("Not expected response type");
            }
        }
Ejemplo n.º 3
0
        public void UpdateVacation(Vacation vacation)
        {
            UpdateVacation UpdateVacation = new UpdateVacation(vacation);

            UpdateVacation.Excute();
        }
Ejemplo n.º 4
0
 public async Task UpdateVacation([FromBody] UpdateVacation command)
 {
     await _commandBus.Send(command);
 }