Example #1
0
        public async Task <IActionResult> UpdateRateAsync([FromRoute, Required] string productKey, [FromRoute, Required] string offeringKey, [FromRoute, Required] string rateKey, [FromBody] UpdateRateDto request)
        {
            try
            {
                var updateRateCommand = new UpdateRateCommand(productKey, offeringKey, rateKey, request.OrderStartDate ?? DateTime.UtcNow, request.OrderEndDate ?? DateTime.MaxValue,
                                                              request.RateClassificationId, request.UnitRetailAmount, request.CommissionAmount,
                                                              request.CommissionPercent, request.CostAmount, request.PostageAmount, request.DeliveryMethodCode, request.TermLength, request.TermUnit, request.Quantity,
                                                              request.NewRenewalRateIndicator, request.EffortKey, request.LegacyIdTitleNumber, request.ListCode, request.RateTypeCode);

                await _mediator.Send(updateRateCommand);

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Something went wrong in AddProductAsync");

                var errorResponse = new ProblemDetails()
                {
                    Title  = "An unexpected error occurred. Please try again later.",
                    Status = StatusCodes.Status500InternalServerError,
                    Detail = ex.Message
                };

                return(StatusCode(StatusCodes.Status500InternalServerError, errorResponse));
            }
        }
        public virtual async Task <IActionResult> Update(long id, [FromBody] UpdateRateCommand command)
        {
            command.Id        = id;
            command.AccountId = User.GetUserId();
            GetRateDto item = await _mediator.Send(command);

            return(Ok(item));
        }