Exemple #1
0
        public JsonResult GetOrderReadinessToStationary(int unitId)
        {
            const int maxCountOrders = 16;

            var pizzeria = _departmentsStructureService.GetPizzeriaOrCache(unitId);

            var orders = _trackerClient
                         .GetOrdersByType(pizzeria.Uuid, OrderType.Stationary, new[] { OrderState.OnTheShelf }, maxCountOrders)
                         .Select(MapToRestaurantReadnessOrders)
                         .ToArray();


            var clientTreatment = pizzeria.ClientTreatment;

            ClientIcon[] icons = { };
            if (clientTreatment == ClientTreatment.RandomImage)
            {
                icons = _clientsService.GetIcons();
            }

            var playTineParamIds = orders.Select(x => x.OrderId).ToArray();

            ViewData["PlayTune"] = playTineParamIds.Except(CurrentProductsIds).Any() ? 1 : 0;
            CurrentProductsIds   = playTineParamIds;

            var result = new
            {
                PlayTune        = (int)ViewData["PlayTune"],
                NewOrderArrived = (int)ViewData["PlayTune"] == 1,
                SongName        = orders.Length == 0 ? DodoFMProxy.GetSongName() : string.Empty,
                ClientOrders    = orders.Select(
                    x => new
                {
                    x.OrderId,
                    x.OrderNumber,
                    x.ClientName,
                    ClientIconPath = clientTreatment == ClientTreatment.RandomImage && icons.Any()
                                ? GetIconPath(x.OrderNumber, icons, "https://wedevstorage.blob.core.windows.net/")
                                : null,
                    OrderReadyTimestamp = x.OrderReadyDateTime.Ticks,
                    OrderReadyDateTime  = x.OrderReadyDateTime.ToString(CultureInfo.CurrentUICulture)
                })
                                  .OrderByDescending(x => x.OrderReadyTimestamp)
            };

            return(Json(result));
        }