/// <summary> /// Implementation of <see cref="ICustomerCommands.RestoreCustomer(Guid)"/> /// </summary> /// <param name="customerId">The customer id</param> /// <returns></returns> public async Task RestoreCustomer(Guid customerId) { if (customerId == Guid.Empty) { throw new ArgumentException("value cannot be empty", nameof(customerId)); } var customer = await Repository.GetByKeyAsync <Customer>(customerId); if (customer == null) { throw new ArgumentOutOfRangeException(nameof(customerId)); } try { customer.Restore(); if (customer.HasAccount && customer.Account.IsLocked) { await AuthClient.EnableAccount(customer.Account.UserId); customer.UnlockAccount(); } await Repository.SaveChangesAsync(); var @event = new CustomerRestoredEvent(customerId); EventBus.RaiseEvent(@event); } catch { throw; } }