Пример #1
0
        /// <summary>
        /// Initialize restaurants start-up stock
        /// </summary>
        /// <param name="date">supplyDate</param>
        public void InitializeStock(DateTime date)
        {
            //Get all mappings and expected stock amounts
            var restaurantProductMappings = _supplyService.GetRestaurantProductMappings(new GetRestaurantProductMappingRequest()).RestaurantProductMappings;
            var mappingCount = restaurantProductMappings.Count;

            //Give order
            Parallel.ForEach(restaurantProductMappings, mapping =>
            {
                //Get
                var responsibleStaff = GetResponsibleStaff(mapping.RestaurantID);
                if (responsibleStaff == null)
                {
                    //LOG
                    return;
                }

                //order the initialize products
                var orderId = _supplyService.GiveOrder(BuildGiveOrderRequest(mapping.RestaurantID, responsibleStaff.ID, mapping.ProductID, mapping.ExpectedStockAmount, date)).OrderID;

                //Given orders are provided by supplier.
                _supplyService.Provide(new ProvideProductOrderRequest
                {
                    OrderID          = orderId,
                    UnitsInStock     = 0,
                    ExpirationDate   = date.AddDays(RandomHelper.RandomInteger(Constants.ProductExpirationDayRange.Min, Constants.ProductExpirationDayRange.Max)),
                    ReceivedDateTime = date
                });
            });
        }