Ejemplo n.º 1
0
        public IActionResult OnPost()
        {
            cityList     = new SelectList(_cityService.FindAllCities(), nameof(City.Id), nameof(City.Name), null, null);
            categoryList = new SelectList(_parcelCategoryService.FindAllCategories(), nameof(ParcelCategory.Id), nameof(ParcelCategory.Name), null, null);
            var parcelDimensionList = Enum.GetValues(typeof(SizeEnum)).Cast <SizeEnum>()
                                      .Select(t => new ParcelInformation
            {
                Id   = ((int)t),
                Name = EnumHelper.GetStringValue(t),
            });

            heightList  = new SelectList(parcelDimensionList, nameof(ParcelInformation.Id), nameof(ParcelInformation.Name), null, null);
            depthList   = new SelectList(parcelDimensionList, nameof(ParcelInformation.Id), nameof(ParcelInformation.Name), null, null);
            breadthList = new SelectList(parcelDimensionList, nameof(ParcelInformation.Id), nameof(ParcelInformation.Name), null, null);

            var parcelInformationList = Enum.GetValues(typeof(WeightEnum)).Cast <WeightEnum>()
                                        .Select(t => new ParcelInformation
            {
                Id   = ((int)t),
                Name = EnumHelper.GetStringValue(t),
            });

            weightList = new SelectList(parcelInformationList, nameof(ParcelInformation.Id), nameof(ParcelInformation.Name), null, null);

            var parcSize     = parcelService.ParseSize(breadthId, heightId, depthId);
            var parcWeight   = parcelService.ParseWeight(weightId);
            var finalPrice   = priceService.GetPrice(parcSize.Id, parcWeight.Id);
            var parcCategory = _parcelCategoryService.findById(categoryId);

            searchResult = _routeService.SearchRoute(_cityService.GetCity(departureCityId), _cityService.GetCity(destinationCityId), finalPrice, parcCategory);

            return(Page());
        }
Ejemplo n.º 2
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));
        }