Beispiel #1
0
        public async Task ShouldInsert_Financier_UsingCreateFinancierInfoWriteModel()
        {
            Guid id    = Guid.NewGuid();
            var  model = new CreateFinancierInfo
            {
                Id            = id,
                FinancierName = "ABC Financiers, Inc.",
                Telephone     = "214-654-9874",
                IsActive      = true,
                UserId        = new Guid("660bb318-649e-470d-9d2b-693bfb0b2744")
            };

            await _financierCmdHdlr.Handle(model);

            Financier result = await _dbContext.Financiers.FindAsync(id);

            Assert.NotNull(result);
        }
        public async Task <IActionResult> CreateFinancierInfo([FromBody] CreateFinancierInfo writeModel)
        {
            try
            {
                await _commandHandler.Handle(writeModel);

                GetFinancier queryParams = new GetFinancier {
                    FinancierID = writeModel.Id
                };

                IActionResult retValue = await _queryRequestHandler.Handle <GetFinancier>(queryParams, HttpContext, Response);

                return(CreatedAtAction(nameof(GetFinancierDetails), new { financierId = writeModel.Id }, (retValue as OkObjectResult).Value));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex.Message));
            }
        }