Ejemplo n.º 1
0
        private void OnResultNotificationOk(IStale <ResponseMessageData <StoreNotificationCategoryModel> > obj)
        {
            if (obj.IsStale)
            {
                OnResultNotificationError(Resources.Network.ResNetwork.ERROR_NETWORK_DOWN);
                return;
            }

            if (obj.Data.IsSuccess == false)
            {
                OnResultNotificationError(obj.Data.Message);
                return;
            }

            var lstData = (obj.Data.LstData as IList <StoreNotificationCategoryModel>) == null ? new List <StoreNotificationCategoryModel>() : obj.Data.LstData.ToList();

            if (!lstData.Any())
            {
                OnResultNotificationError("No hay una sucursal disponible en la dirección que seleccionó");
                return;
            }

            RxApp.MainThreadScheduler.Schedule(_ =>
            {
                try
                {
                    LstNotificaionCategories.ClearAndAddRange(
                        lstData.OrderBy(e => e.Position).Select(e => new StoreNotificationCategoryViewModel
                    {
                        CategoryName    = e.CategoryName,
                        Color           = e.Color,
                        NotificationsVm = e.Notifications.Select(i => new MessageNotificationVm
                        {
                            ItemImage = string.IsNullOrWhiteSpace(i.Resource)
                                    ? null
                                    : new BitmapImage(
                                new Uri(
                                    (SharedConstants.Client.URI_IMAGE_NOTIFICATION + i.Resource)
                                    .AbsolutePathRelativeToEntryPointLocation())),
                            Message = i.Message
                        }).ToList(),
                        Position = e.Position
                    }));
                }
                catch (Exception ex)
                {
                    OnResultNotificationError(ex);
                }
            });
        }
Ejemplo n.º 2
0
        public void OnChangeStore(ItemCatalog item, bool bIsLastStore)
        {
            if (SettingsData.Store.EnableStoreNotifications == false)
            {
                return;
            }

            RxApp.MainThreadScheduler.Schedule(_ => LstNotificaionCategories.Clear());

            DisposeSubscription();

            _subscription = _client.ExecutionProxy.ExecuteRequest <int, int, ResponseMessageData <StoreNotificationCategoryModel>,
                                                                   ResponseMessageData <StoreNotificationCategoryModel> >(item.Id, TransferDto.SameType, SharedConstants.Server.STORE_HUB,
                                                                                                                          SharedConstants.Server.GET_NOTIFICATIONS_BY_STORE_STORE_HUB_METHOD, TransferDto.SameType)
                            .Subscribe(OnResultNotificationOk, OnResultNotificationError);
        }