Beispiel #1
0
        public double GetPrice(int weightId, int sizeId)
        {
            var        weight     = context.ParcelWeight.SingleOrDefault(x => x.Id == weightId);
            var        size       = context.ParcelSize.SingleOrDefault(x => x.Id == sizeId);
            var        sizeList   = parcelService.FindAllParcelSizes();
            var        priceList  = parcelService.FindAllParcelPrices();
            ParcelSize returnSize = null;

            foreach (var parc in sizeList)
            {
                if (size.Breadth <= parc.Breadth && size.Height <= parc.Height && size.Depth <= parc.Depth)
                {
                    returnSize = parc;
                    break;
                }
            }
            if (returnSize is null)
            {
                return(0.0);
            }

            ParcelPrice returnPrice = null;

            foreach (var parc in priceList)
            {
                if (parc.Size == size && parc.Weight.Weight == parc.Weight.Weight)
                {
                    returnPrice = parc;
                    break;
                }
            }


            return(returnPrice.Price);
        }
Beispiel #2
0
        public HomeModule()
        {
            Get["/"] = _ => {
                return(View["order-form.cshtml"]);
            };

            Get["/dimensions"] = _ => {
                int         length        = (Request.Query["length"]);
                int         width         = (Request.Query["width"]);
                int         weight        = (Request.Query["weight"]);
                ParcelPrice myParcelPrice = new ParcelPrice(length, width, weight);
                return(View["cost-page.cshtml", myParcelPrice]);
            };
        }
Beispiel #3
0
 public ParcelTypeDTO(ParcelPrice parcelPrice)
 {
     Name   = parcelPrice.Size.Name;
     Size   = new ParcelSizeDTO(parcelPrice.Size);
     Weight = new ParcelWeightDTO(parcelPrice.Weight);
 }