public CounterItem(Counter counter, Storage.Models.Organization organization) { CounterObject = counter; Organization = organization; CounterName = counter.CounterName; SubscriptionButtonCommand = new SubscribeButtonClick(); CheckSubscription(); }
public async Task FetchCounters(string organizationId) { ResponseData responseData = await CounterService.GetCountersByOrganization(organizationId); if (responseData.ResponseType.Equals(Constants.ErrorString)) { var error = responseData.Payload.ToObject<ErrorResponse>(); await OverlayProgressBar.Instance.HideAndDisplayErrorMessage(error.ErrorMessage); } else { var collection = responseData.Payload.ToObject<Counters>(); Storage.Models.Organization organization = new Storage.Models.Organization { Id= collection.OrganizationId, Name= collection.OrganizationName, City= collection.OrganizationCity }; Counters= new ObservableCollection<CounterItem>(collection.counters.Select(s=> new CounterItem(s, organization))); System.Diagnostics.Debug.WriteLine("Counters: " + Counters.Count); await OverlayProgressBar.Instance.HideAndDisplayErrorMessage(); } }
public async Task AddEntry() { await OverlayProgressBar.Instance.ShowAndHideAfterTimeOut("Adding counter...", _currentPage); ResponseData responseData = await ConnectionManager.SendRequestPacket<AddCounterRequest>("addCounter.php", new AddCounterRequest(CounterName, _organizationId)); if (responseData.ResponseType.Equals(Constants.ErrorString)) { var error = responseData.Payload.ToObject<ErrorResponse>(); await OverlayProgressBar.Instance.HideAndDisplayErrorMessage(error.ErrorMessage); } else { var collection = responseData.Payload.ToObject<Counters>(); Counters.Clear(); Storage.Models.Organization organization = new Storage.Models.Organization { Id = collection.OrganizationId, Name = collection.OrganizationName, City = collection.OrganizationCity }; foreach (Counter counter in collection.counters) { Counters.Add(new CounterItem(counter, organization)); } await OverlayProgressBar.Instance.HideAndDisplayErrorMessage(); } }