public VotingFacade(string connectionString) { var optionBuilder = new DbContextOptionsBuilder <VotingPlatformContext>(); optionBuilder.UseSqlServer(connectionString); ctx = new VotingPlatformContext(optionBuilder.Options); this.iVoting = new VotingRepository(ctx); }
private async void GetData() { IPeopleRepository repository = PeopleRepository.Instance; try { IVoting glosowanie = await repository.GetSejmVoting(id); tvTytul.Text = glosowanie.Tytul; tvCzas.Text = glosowanie.Czas; if (glosowanie.Wynik == 2) { tvWynik.Text = "Ustawa Odrzucona"; tvWynik.SetTextColor(Android.Graphics.Color.ParseColor("#E00909")); } var glosy = glosowanie.Glosy; var glosyZa = glosy.Where(item => item.Glos == 1).ToList(); var glosyPrzeciw = glosy.Where(item => item.Glos == 2).ToList(); var glosyWstrzymalSie = glosy.Where(item => item.Glos == 3).ToList(); var glosyNieobecny = glosy.Where(item => item.Glos == 4).ToList(); fragmentsTabs.Add("Za (" + glosyZa.Count + ")", new VotingPeopleListFragment(glosyZa)); fragmentsTabs.Add("Przeciw (" + glosyPrzeciw.Count + ")", new VotingPeopleListFragment(glosyPrzeciw)); fragmentsTabs.Add("Wstrzymał się (" + glosyWstrzymalSie.Count + ")", new VotingPeopleListFragment(glosyWstrzymalSie)); fragmentsTabs.Add("Nieobecny (" + glosyNieobecny.Count + ")", new VotingPeopleListFragment(glosyNieobecny)); var tabs = Activity.FindViewById <com.refractored.PagerSlidingTabStrip> (Resource.Id.tabs); var pager = Activity.FindViewById <ViewPager> (Resource.Id.pager); tabs.ShouldExpand = false; pager.Adapter = new UniversalFragmentPagerAdapter(FragmentManager, fragmentsTabs); tabs.SetViewPager(pager); if (viewSwitcher.CurrentView != contentLayout) { viewSwitcher.ShowPrevious(); } } catch (ApiRequestException ex) { (Activity as BaseActivity).ShowErrorDialog(ex.Message); } catch (Exception exc) { //raportowanie błędów przy ładowaniu danych Xamarin.Insights.Report(exc); } }
public void StartService() { var binding = new NetPeerTcpBinding(); binding.Security.Mode = SecurityMode.None; var endpoint = new ServiceEndpoint( ContractDescription.GetContract(typeof(IVoting)), binding, new EndpointAddress("net.p2p://P2P")); Host = new VotingImplementation(); _factory = new DuplexChannelFactory <IVoting>( new InstanceContext(Host), endpoint); var channel = _factory.CreateChannel(); ((ICommunicationObject)channel).Open(); Channel = channel; }
async public Task <IVoting> GetSejmVoting(int id) { try { IJsonObjectRequestHandler <Voting> handler = new JsonObjectRequestHandler <Voting> (ConnectionProvider.Instance); var request = new RequestParamsHandler(String.Concat(RepositoriesContants.API_BASE_URI, "sejm_glosowania/", id)); request.AddField("sejm_glosowania.id"); request.AddField("sejm_glosowania.wynik_id"); request.AddField("sejm_glosowania.tytul"); request.AddField("sejm_glosowania.czas"); request.Layers.Add(new SejmGlosowanieLayer("wynikiIndywidualne")); IVoting p = await handler.GetJsonObjectAsync(request); return(p); } catch (IOException ex) { System.Diagnostics.Debug.WriteLine("IOException on GetJsonObjectAsync", ex.ToString()); throw new ApiRequestException(String.Concat("Problem z połączeniem:\n", ex.Message)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("GetJsonObjectAsync", ex.ToString()); throw new ApiRequestException(String.Concat("Problem z dostępem do API:\n", ex.Message)); } }
public void TestInitialize() { _voting = new Voting(); }
public HomeController(IVoting votacao) { _votacao = votacao; }