public async Task <IActionResult> UpdateAsync([FromBody] UpdateInvoiceModel model)
        {
            try
            {
                model.ValidateDueDate();

                var invoice = Mapper.Map <Invoice>(model);

                await _invoiceService.UpdateDraftAsync(invoice);

                return(NoContent());
            }
            catch (InvoiceDueDateException ex)
            {
                _log.WarningWithDetails(ex.Message, model.Sanitize());

                return(BadRequest(ErrorResponse.Create(ex.Message)));
            }
            catch (InvoiceNotFoundException ex)
            {
                _log.WarningWithDetails(ex.Message, model.Sanitize());

                return(NotFound(ErrorResponse.Create("Invoice with such Id and MerchantId not found")));
            }
            catch (InvalidOperationException ex)
            {
                _log.WarningWithDetails(ex.Message, model.Sanitize());

                return(BadRequest(ErrorResponse.Create(ex.Message)));
            }
        }
        public async Task UpdateAsync(UpdateInvoiceModel model, bool draft)
        {
            model.PaymentAssetId = _lykkeAssetsResolver.GetInvoiceCreationPair(model.SettlementAssetId);

            try
            {
                await _payInvoiceClient.UpdateDraftInvoiceAsync(model);

                if (!draft)
                {
                    await _payInvoiceClient.CreateInvoiceAsync(model.Id);
                }
            }
            catch (ErrorResponseException ex)
            {
                _log.ErrorWithDetails(ex, new { model = model.Sanitize(), draft });

                throw new InvalidOperationException(ex.Message);
            }
        }