Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] CreateExpense command, Guid settlementId)
        {
            command.CurrentUserId = CurrentUserId;
            command.SettlementId  = settlementId;
            await _commandDispatcher.DispatchAsync(command);

            return(Created($"/settlement/{command.SettlementId}", null));
        }
        public async Task <IActionResult> CreateExpense(CreateExpense command)
        {
            try
            {
                _logger.LogInformation("CreateExpense method fired on {date}", DateTime.Now);
                var result = await _mediator.Send(command);

                _logger.LogInformation("CreateExpense method task finished on {date}", DateTime.Now);
                return(Ok(result));
            }
            catch (Exception e)
            {
                _logger.LogInformation("CreateExpense method task finished on {date}", DateTime.Now);
                _logger.LogError($"Error in CreateExpense method: {e.Message}");
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error in CreateExpense method"));
            }
        }