예제 #1
0
        private List <InternalOrder> BuildOrders(IEnumerable <InternalOrder> temp)
        {
            var result = new List <InternalOrder>();

            foreach (InternalOrder item in temp)
            {
                for (int i = 0; i < item.LengthOfStay; i++)
                {
                    var order = new InternalOrder
                    {
                        BookingTime  = item.BookingTime,
                        CheckIn      = item.CheckIn.AddDays(i),
                        Type         = item.Type,
                        LengthOfStay = item.LengthOfStay,
                        RoomPrice    = item.RoomPrice,
                        MealPrice    = item.MealPrice,
                        RoomType     = item.RoomType,
                        CategoryInfo = item.CategoryInfo,
                        Status       = item.Status,
                        MealType     = item.MealType
                    };
                    BuildOrder(order);
                    result.Add(order);
                }
            }

            return(result);
        }
예제 #2
0
        private void BuildOrder(InternalOrder order, bool withCategory)
        {
            order.SeasonType = 0;
            int w = order.CheckIn.GetWeekNumber();

            foreach (SeasonDescription x in _config.ConfigurationRoot.Seasons.SeasonDescriptions)
            {
                if (w >= x.Start && w <= x.Finish)
                {
                    order.SeasonType = x.Number;
                    break;
                }
            }
            order.WeekdayType = 0;
            switch (order.CheckIn.DayOfWeek)
            {
            case DayOfWeek.Sunday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Sunday; break;

            case DayOfWeek.Monday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Monday; break;

            case DayOfWeek.Tuesday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Tuesday; break;

            case DayOfWeek.Wednesday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Wednesday; break;

            case DayOfWeek.Thursday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Thursday; break;

            case DayOfWeek.Friday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Friday; break;

            case DayOfWeek.Saturday: order.WeekdayType = _config.ConfigurationRoot.Weekdays.Saturday; break;
            }
            if (withCategory)
            {
                order.CategoryInfo = _config.ConfigurationRoot.GetCategoryId(order.LengthOfStay, (order.CheckIn.Date - order.BookingTime.Date).Days);
                //order.CategoryInfo = 0;
                //foreach (OptionDescription x in _config.ConfigurationRoot.Categories.StayPeriods)
                //    if (order.LengthOfStay >= x.LowerBound && order.LengthOfStay <= x.UpperBound)
                //    {
                //        order.CategoryInfo = x.Number;
                //        break;
                //    }
                //var total = _config.ConfigurationRoot.Categories.BookingPeriods.Count();
                //if (total > 0)
                //    order.CategoryInfo *= total;
                //foreach (OptionDescription x in _config.ConfigurationRoot.Categories.BookingPeriods)
                //    if ((order.CheckIn.Date - order.BookingTime.Date).Days >= x.LowerBound && (order.CheckIn.Date - order.BookingTime.Date).Days <= x.UpperBound)
                //    {
                //        order.CategoryInfo += x.Number;
                //        break;
                //    }
            }
        }
예제 #3
0
 private IEnumerable <InternalOrder> ParseOrders(string ordersPath)
 {
     return(System.IO.File.ReadAllLines(ordersPath).Select(x =>
     {
         string[] s = x.Split(';');
         var item = new InternalOrder
         {
             BookingTime = DateTime.Parse(s[0]),
             CheckIn = DateTime.Parse(s[1]),
             LengthOfStay = int.Parse(s[2]),
             RoomPrice = double.Parse(s[3]),
             RoomType = int.Parse(s[4]),
             Type = (BookingType)int.Parse(s[5]),
             Status = (BookingStatus)int.Parse(s[6]),
             MealType = s.Length < 8?0:int.Parse(s[7])
         };
         BuildOrder(item, true);
         return item;
     }));
 }