コード例 #1
0
        /**
         * Determine whether a provided day is a no-shipping holiday
         */
        public bool validShippingDate(DateTime shippingDate)
        {
            if (!shipOnWeekends && (shippingDate.DayOfWeek == DayOfWeek.Saturday ||
                                    shippingDate.DayOfWeek == DayOfWeek.Sunday))
            {
                return(false);
            }

            if (HolidayRepository.all()
                .Any(holiday => holiday.month == shippingDate.Month && holiday.day == shippingDate.Day))
            {
                return(false);
            }

            if (manufacturer.holidays.Any(holiday =>
                                          holiday.month == shippingDate.Month && holiday.day == shippingDate.Day))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
 public ProductViewModel(Product product)
 {
     productId             = product.productId;
     productLink           = $"/products/{productId}";
     productName           = product.productName;
     manufacturerName      = product.manufacturer.name;
     inventoryQuantity     = product.inventoryQuantity;
     shipOnWeekends        = product.shipOnWeekends ? "Yes" : "No";
     shippingHolidays      = JsonSerializer.Serialize(product.manufacturer.holidays.Concat(HolidayRepository.all()).ToList());
     maxBusinessDaysToShip = product.maxBusinessDaysToShip;
     estimatedArrival      = product.getArrivalDate(DateTime.Now).ToLongDateString();
 }