public async Task <int> LogCommandProcessingAsync(string messageName, string machine, int thread, DateTime createdOn)
        {
            await commandBus.SendCommandAsync(new LogCommandProcessing
            {
                MessageName = messageName,
                CreatedOn   = createdOn,
                Machine     = machine,
                Thread      = thread
            });

            return(1);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetShippingCost(CostPackageRequest costPackageRequest)
        {
            var validationResult = await new CostPackageRequestValidator().ValidateAsync(costPackageRequest);

            if (!validationResult.IsValid)
            {
                return(new BadRequestObjectResult(new ApiResponseBase
                {
                    Success = false, Message = validationResult.Errors.FirstOrDefault()?.ErrorMessage
                }));
            }

            var command = Mapper.Map <PackageCostQueryCommand>(costPackageRequest);
            var package = await CommandBus.SendCommandAsync <PackageCostQueryCommandResponse>(command);

            var costPackageResponse = package.MapTo <CostPackageResponse>(Mapper);

            if (Notifications.HasErrorsOrValidations)
            {
                costPackageResponse.Success = false;
                costPackageResponse.Message = Notifications.ToApiResponseValidations().FirstOrDefault()?.Message;
            }
            else if (package.PackageType == PackageType.Undefined)
            {
                costPackageResponse.Success = false;
                costPackageResponse.Message = ShippingMessages.UnableIdentifySize;
            }
            else
            {
                costPackageResponse.Success = true;
                costPackageResponse.Message = ShippingMessages.PackageSuccessfullyCalculated;
            }

            if (costPackageResponse.Success)
            {
                return(new OkObjectResult(costPackageResponse));
            }

            return(new BadRequestObjectResult(new ApiResponseBase
            {
                Success = false, Message = ShippingMessages.UnableIdentifySize
            }));
        }
        public async Task <IHttpActionResult> Post([FromBody] LogEventProcessing toPost)
        {
            await commandBus.SendCommandAsync(toPost);

            return(Ok());
        }