示例#1
0
        public ActionResult GetOutPut([FromQuery] IntegrationInput integrationInput)
        {
            ICollection <RouteIntegrationDTO> routes = new List <RouteIntegrationDTO>();
            var listSegments = segmentService.FindAllSegments();

            var parcelWeight = parcelService.ParseWeight(integrationInput.Weight);
            var parcelSize   = parcelService.ParseSize(integrationInput.Breadth, integrationInput.Height, integrationInput.Height);

            var price = priceService.GetPrice(parcelWeight.Id, parcelSize.Id);

            if (string.IsNullOrEmpty(integrationInput.Category))
            {
                integrationInput.Category = otherCategory;
            }

            var parcelCategory = parcelService.GetCategoryByCode(integrationInput.Category);

            if (parcelCategory == null)
            {
                return(NotFound("Category is not supported"));
            }

            foreach (Segment seg in listSegments)
            {
                routes.Add(new RouteIntegrationDTO
                {
                    From     = seg.From.Code.Replace("\r\n", ""),
                    To       = seg.To.Code.Replace("\r\n", ""),
                    IsTwoWay = true,
                    Price    = (Decimal)(price * (1 + parcelCategory.ExtraCharge / 100)),
                    Segments = 1,
                    Time     = 8,
                });
            }
            var dataOutput = new IntegrationDTO
            {
                CompanyName  = "Oceanic Airline",
                ShippingType = "Air",
                Routes       = routes
            };

            return(Ok(dataOutput));
        }