public async Task <ActionResult <FeeQuoteConfigViewModelGet> > Post([FromBody] FeeQuoteViewModelCreate data) { logger.LogInformation($"Create new FeeQuote form data: {data} ."); data.CreatedAt = clock.UtcNow(); var domainModel = data.ToDomainObject(clock.UtcNow()); var br = this.ReturnBadRequestIfInvalid(domainModel); if (br != null) { return(br); } var newFeeQuote = await feeQuoteRepository.InsertFeeQuoteAsync(domainModel); if (newFeeQuote == null) { var problemDetail = ProblemDetailsFactory.CreateProblemDetails(HttpContext, (int)HttpStatusCode.BadRequest); problemDetail.Status = (int)HttpStatusCode.BadRequest; problemDetail.Title = $"FeeQuote not created. Check errors."; return(BadRequest(problemDetail)); } var returnResult = new FeeQuoteConfigViewModelGet(newFeeQuote); logger.LogInformation($"FeeQuote(id) {returnResult.Id} was generated."); return(CreatedAtAction(nameof(GetFeeQuoteById), new { id = returnResult.Id }, returnResult)); }
public ActionResult <FeeQuoteConfigViewModelGet> GetFeeQuoteById(long id) { logger.LogInformation($"Get FeeQuote {id}"); FeeQuote feeQuote = feeQuoteRepository.GetFeeQuoteById(id); if (feeQuote == null) { return(NotFound()); } var feeQuoteViewModelGet = new FeeQuoteConfigViewModelGet(feeQuote); return(Ok(feeQuoteViewModelGet)); }