コード例 #1
0
        public override async Task <AddFreightResponse> AddFreight(AddFreightRequest request, ServerCallContext context)
        {
            CreateFreightCommand command = new CreateFreightCommand
            {
                Width       = request.Freight.Width,
                Height      = request.Freight.Height,
                Length      = request.Freight.Length,
                Weight      = request.Freight.Weight,
                FreightType = (Models.FreightType)request.Freight.FreightType,
                CreateDate  = DateTime.Now
            };
            Guid id = _mediator.Send(command).Result;
            AddFreightResponse response = new AddFreightResponse {
                Id = id.ToString()
            };

            return(await Task.FromResult(response));
        }
コード例 #2
0
        public override async Task <AddFreightResponse> AddFreight(AddFreightRequest request, ServerCallContext context)
        {
            var freightModel      = new FreightModel(request.Freight.Location, request.Freight.Destination, request.Freight.Cargo, request.Freight.Status, request.Freight.Payment);
            var addFreightComamnd = new AddFreightCommand(freightModel);
            var result            = await _mediator.Send(addFreightComamnd);

            if (result == null)
            {
                return(null);
            }
            var response = new AddFreightResponse();

            response.Freight             = new FreightMessage();
            response.Freight.Id          = result.Id;
            response.Freight.Location    = result.Location;
            response.Freight.Destination = result.Destination;
            response.Freight.Cargo       = result.Cargo;
            response.Freight.Status      = result.Status;
            response.Freight.Payment     = result.Payment;
            return(response);
        }