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); }
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"); } }
public void UpdateVacation(Vacation vacation) { UpdateVacation UpdateVacation = new UpdateVacation(vacation); UpdateVacation.Excute(); }
public async Task UpdateVacation([FromBody] UpdateVacation command) { await _commandBus.Send(command); }