public override void Initialize() { base.Initialize(); items = new ReactiveList <HudStoreItemViewModel>(); filter = new ReadOnlyObservableCollection <HudStoreFilter>( new ObservableCollection <HudStoreFilter>(Enum.GetValues(typeof(HudStoreFilter)).OfType <HudStoreFilter>())); sorting = new ReadOnlyObservableCollection <HudStoreSorting>( new ObservableCollection <HudStoreSorting>(Enum.GetValues(typeof(HudStoreSorting)).OfType <HudStoreSorting>())); GridColumns = 4; GridRows = 1; var licenseService = ServiceLocator.Current.GetInstance <ILicenseService>(); var license = licenseService.GetHudStoreLicenseInfo(true); var loadInfo = new HudStoreGetHudsRequest { Serial = license?.Serial }; Model.ObservableForProperty(x => x.SelectedFilter).Select(x => true) .Merge(Model.ObservableForProperty(x => x.SelectedSorting).Select(x => true)) .Subscribe(x => { StartAsyncOperation(() => Model.Refresh(0, ProductsPerPage), ex => OnUpdated()); }); InitializeModelAsync(() => { Model.Load(loadInfo); }); }
public override void Refresh(int page, int amount) { var request = new HudStoreGetHudsRequest { Serial = serial, Page = page, Filter = (int)SelectedFilter, Sorting = (int)SelectedSorting, Search = searchText }; hudsData = service.GetHuds(request); itemsCount = hudsData.ItemsCount; }
/// <summary> /// Gets available layouts /// </summary> /// <param name="page">Number of page</param> /// <param name="limit">Amount of layouts to select</param> /// <returns><see cref="HudStoreHudsData"/></returns> public HudStoreHudsData GetHuds(HudStoreGetHudsRequest request) { try { if (string.IsNullOrEmpty(request.Serial)) { throw new DHBusinessException(new NonLocalizableString("Unknown serial number")); } request.Serial = SecurityUtils.EncryptStringRSA(request.Serial, encryptKey); var jsonString = JsonConvert.SerializeObject(request); var requestData = new Dictionary <string, string> { ["data"] = jsonString }; var formUrlEncodedContent = new FormUrlEncodedContent(requestData); var serviceResponse = Post <HudStoreHudsData>(HudStoreServiceNames.HudsService, HudStoreServiceCommands.GetAll, formUrlEncodedContent); if (serviceResponse != null && serviceResponse.Result != null && (serviceResponse.Errors == null || serviceResponse.Errors.Length == 0)) { return(serviceResponse.Result); } var errorMessage = ConvertErrors(serviceResponse?.Errors); throw new DHBusinessException(new LocalizableString("Common_HudWebService_GettingHudFailed", errorMessage)); } catch (DHBusinessException) { throw; } catch (Exception e) { throw new DHInternalException(new NonLocalizableString("Couldn't get huds from hud store web service."), e); } }