public async Task CourtDeleteTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var townService = new CourtTownService(dbContext); await townService.CreateAsync("Rousse", "Боримечка 43"); await townService.CreateAsync("София", "Боримечка 44"); var townId = dbContext.CourtTowns.Where(x => x.Id == 1) .Select(x => x.Id) .FirstOrDefault(); var courtService = new CourtService(dbContext); await courtService.CreateAsync("Районен", townId); await courtService.CreateAsync("Окръжен", townId); var courtId = dbContext.Courts.Where(x => x.CourtType.ToString() == "Окръжен") .Select(x => x.Id).FirstOrDefault(); //Act var result = courtService.DeleteAsync(courtId); var myCourt = dbContext.Courts.Where(x => x.Id == courtId) .Select(x => x.CourtTown.TownName).FirstOrDefault(); //Assert Assert.Null(myCourt); //Assert.True(result.IsCompletedSuccessfully); }
public PacerDataMgmt() { InitializeComponent(); _courts = CourtService.GetAll(); cboCourt.ItemsSource = _courts; grdCourts.ItemsSource = _courts; List <PacerFileFormat> _formats = PacerFileFormatService.GetAll(); cboECFVersion.ItemsSource = _formats; rdpEndDate.SelectedDate = DateTime.Now.AddDays(-1); rdpStartDate.SelectedDate = DateTime.Now.AddMonths(-1); _asyncWorker = new BackgroundWorker(); _asyncWorker.WorkerReportsProgress = true; _asyncWorker.WorkerSupportsCancellation = true; _asyncWorker.ProgressChanged += new ProgressChangedEventHandler(bwAsync_ProgressChanged); _asyncWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAsync_RunWorkerCompleted); _asyncWorker.DoWork += new DoWorkEventHandler(bwAsync_DoWork); _asyncZipStatusWorker = new BackgroundWorker(); _asyncZipStatusWorker.WorkerReportsProgress = true; _asyncZipStatusWorker.WorkerSupportsCancellation = true; _asyncZipStatusWorker.ProgressChanged += new ProgressChangedEventHandler(bwAsyncZip_ProgressChanged); _asyncZipStatusWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAsyncZip_RunWorkerCompleted); _asyncZipStatusWorker.DoWork += new DoWorkEventHandler(bwAsyncZip_DoWork); }
public async Task CourtEditTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var townService = new CourtTownService(dbContext); await townService.CreateAsync("Rousse", "Боримечка 43"); await townService.CreateAsync("Rousse", "Боримечка 44"); var town = dbContext.CourtTowns.Where(x => x.Id == 1) .Select(x => x.Id) .FirstOrDefault(); var courtService = new CourtService(dbContext); await courtService.CreateAsync("Окръжен", town); await courtService.CreateAsync("Районен", town); var courtId = dbContext.Courts.Where(x => x.Id == 0) .Select(x => x.Id) .FirstOrDefault(); var result = courtService.EditAsync(courtId, "окръжен", 1); var courtType = await courtService.DetailsAsync(1); Assert.True(result.IsCompletedSuccessfully); // Assert.Equal("окръжен", courtType.CourtType.ToString()); Assert.NotNull(result); }
public async Task CourtAllTest() { //Arrange //var courtTown = new CourtTown //{ // Id = 1, // TownName = "Rousse", // Address = "myAddress" //}; var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb"); var dbContext = new ApplicationDbContext(optionBuilder.Options); //await dbContext.CourtTowns.AddAsync(courtTown); //await dbContext.SaveChangesAsync(); var service = new CourtService(dbContext); //Act var result = await service.AllAsync(); //Assert Assert.NotNull(result); Assert.IsType <List <CourtAllViewModel> >(result); //Assert.Equal("Rousse", result.Result.TownName); //Assert.Equal("myAddress", result.Result.Address); //Assert.Equal(1, result.Result.Id); }
public MainWindow() { InitializeComponent(); _courts = CourtService.GetAll(); cboCourt.ItemsSource = _courts; }
public SelectionController(StvContext db) { _db = db; candidateService = new CandidateService(db); credentialService = new CredentialService(db); selectionService = new SelectionService(db); settingService = new SettingService(db); courtService = new CourtService(db); }
private void btnCheckCourtVersion_Click(object sender, RoutedEventArgs e) { //ECFVersionByCourt _ecf = new ECFVersionByCourt(); //List<ECFVersion> _versions = _ecf.GetBankruptcyCourtVersions(); if (cboCourt.SelectedIndex == -1) { MessageBox.Show("Please Select a Court!"); return; } else { try { Mouse.OverrideCursor = Cursors.Wait; Court _court = (Court)cboCourt.SelectedValue; ECFVersionByCourt _version = new ECFVersionByCourt(); ECFVersion _ecfVersion = _version.GetBankruptcyCourtVersion(_court.CourtName); if (_court.PacerFileVersion == _ecfVersion.versionString) { MessageBox.Show("Versions match!: " + _ecfVersion.versionString); } else { //get the corresponding ID; PacerFileFormat _format = PacerFileFormatService.GetByVersionString(_ecfVersion.versionString); if (_format == null) { MessageBox.Show("Unknown Version: " + _ecfVersion.versionString); } else { _court.PacerFileFormatID = _format.ID; _court.PacerFileVersion = _format.PacerFileVersion; CourtService.Save(_court); cboECFVersion.SelectedIndex = 0; MessageBox.Show("Court Version updated to: " + _ecfVersion.versionString); //LoadCourts(); } } Mouse.OverrideCursor = Cursors.Arrow; //MessageBox.Show(_ecfVersion.versionString); } catch (Exception ex) { MessageBox.Show("Error: " + ex.ToString()); Mouse.OverrideCursor = Cursors.Arrow; } } }
private void LoadCourts() { _courts = CourtService.GetAll(); cboCourt.ItemsSource = null; cboCourt.Items.Clear(); cboCourt.ItemsSource = _courts; grdCourts.ItemsSource = null; grdCourts.Items.Clear(); grdCourts.ItemsSource = _courts; }
public void CourtGetAllTownsTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var service = new CourtService(dbContext); var result = service.GetAllCourtTowns(); Assert.NotNull(result); Assert.IsType <List <KeyValuePair <string, string> > >(result.ToList()); }
private void LoadCourts() { _blnLoadingCourts = true; _courts = CourtService.GetAll(); cboCourt.ItemsSource = null; cboCourt.Items.Clear(); cboCourt.ItemsSource = _courts; grdCourts.ItemsSource = null; grdCourts.Items.Clear(); grdCourts.ItemsSource = _courts; _blnLoadingCourts = false; }
public async Task CourtCreateTest() { var optionBuilder = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("testDb"); var dbContext = new ApplicationDbContext(optionBuilder.Options); var service = new CourtService(dbContext); var result = service.CreateAsync("Районен", 1); var courtType = await dbContext.Courts.Where(x => x.Id == 1).Select(c => c.CourtType) .FirstOrDefaultAsync(); Assert.True(result.IsCompletedSuccessfully); Assert.Equal("Районен", courtType.ToString()); }
//private void btnUpdateVersion_Click(object sender, RoutedEventArgs e) //{ // //ECFVersionByCourt _ecf = new ECFVersionByCourt(); // //List<ECFVersion> _versions = _ecf.GetBankruptcyCourtVersions(); // if (cboCourt.SelectedIndex == -1) // { // MessageBox.Show("Please Select a Court!"); // return; // } // else if (cboECFVersion.SelectedIndex == -1) // { // MessageBox.Show("Please Select an ECF Version!"); // return; // } // else // { // try // { // Court _court = (Court)cboCourt.SelectedValue; // //get the corresponding ID; // _court.PacerFileFormatID = ((PacerFileFormat)cboECFVersion.SelectedValue).ID; // CourtService.Save(_court); // MessageBox.Show("Version updated to " + ((PacerFileFormat)cboECFVersion.SelectedValue).PacerFileVersion + " for court: " + _court.CourtName); // lblECFVersion.Content = ((PacerFileFormat)cboECFVersion.SelectedValue).PacerFileVersion; // cboECFVersion.SelectedIndex = -1; // } // catch (Exception ex) // { // MessageBox.Show("Error: " + ex.ToString()); // } // } //} private void btnCheckCourtVersions_Click(object sender, RoutedEventArgs e) { //ECFVersionByCourt _ecf = new ECFVersionByCourt(); //List<ECFVersion> _versions = _ecf.GetBankruptcyCourtVersions(); try { Mouse.OverrideCursor = Cursors.Wait; MessageBox.Show(CourtService.CheckECFVersions(), "PACER ECF Version Update Results!"); Mouse.OverrideCursor = Cursors.Arrow; } catch (Exception ex) { MessageBox.Show("Error: " + ex.ToString()); Mouse.OverrideCursor = Cursors.Arrow; } }
public MainWindow() { List <State> _states; List <Court> _courts; InitializeComponent(); if (ConfigurationManager.AppSettings.Get("Debug") == "true") { MessageBox.Show("I'm here"); } //set the Pacer Management Window rtPacerDataMgmt.Content = new PacerDataMgmt(); _courts = CourtService.GetAll(); cboCourt.ItemsSource = _courts; // export filter criteria //_courts.Insert(0, new Court(){CourtName="[Select...]"}); cboCourtExportCriteria.ItemsSource = _courts; _states = StateService.GetActive(); //_states.Insert(0, new State() { StateCode = "[Select...]" }); cboState.ItemsSource = _states; //LoadAndProcessRemoveEmails(); //if (DateTime.Now > DateTime.Parse("02/01/12")) //{ // MessageBox.Show("Your system has outstanding invoices due. Please contact Metamorpho-Sys for scheduling payment at (503) 901-5395"); // if (DateTime.Now > DateTime.Parse("04/01/12")) // { // MessageBox.Show("Your system has outstanding invoices due. Please contact Metamorpho-Sys for scheduling payment at (503) 901-5395. Applciation will now close"); // this.Close(); // } //} List <Dealer> _dealers = DealerService.GetFiltered(string.Empty, true); GridViewDealers.ItemsSource = _dealers; //_dealers.Insert(0, new Dealer() { CompanyName = "[Select...]" }); cboDealerExportCriteria.ItemsSource = _dealers; }
public void CourtServiceTestsInitialize() { var courtRepo = new Mock <IUnitOfWork>(); courtRepo.Setup(r => r.GetIDbSet <Court>()).Returns(new FakeDbSet <Court>(new Court { OpeningTime = new TimeSpan(9, 0, 0), ClosingTime = new TimeSpan(22, 0, 0), CreatedBy = "Mock", Id = 1, CreationdDate = new DateTime(1977, 2, 9), IsActive = true, UpdatedDate = DateTime.Now, UpdatedBy = "Mock", Name = "Test Court" })); courtService = new CourtService(courtRepo.Object); }
protected override async Task OnParametersSetAsync() { switch (Page) { case null: case "lights": if (Lights is null) { Lights = await LightService.GetAllAsync(); } break; case "heats": if (Heats is null) { Heats = await HeatService.GetAllAsync(); } break; case "courts": if (Courts is null) { Courts = await CourtService.GetAllAsync(); } break; case "rates": if (Rates is null) { Rates = await RatesService.GetAllAsync(); } break; default: throw new KeyNotFoundException("Dashboard nested page not found!"); } }
private void bwAsync_DoWork(object sender, DoWorkEventArgs e) { try { // The Sender is the BackgroundWorker object we need it to // report progress and check for cancellation. BackgroundWorker bwAsync = sender as BackgroundWorker; MutipleProcessSpec _spec = (MutipleProcessSpec)e.Argument; int i = 0; string _state = "Checking ECF Versions..."; bwAsync.ReportProgress(0, _state); _state = CourtService.CheckECFVersions(); bwAsync.ReportProgress(0, _state); Thread.Sleep(1000); foreach (object _court in _spec.Courts) { i++; //refresh court from ID to get version that may have been updated CourtService.Refresh((Court)_court); if ((_spec.FiledOnly == true && (((Court)_court).LastPacerLoadFileDate == DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()))) || (_spec.FiledOnly == false && (((Court)_court).LastPacerLoadDischargeDate == DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString())))) { //do nothing } else { // Periodically report progress to the main thread so that it can // update the UI. _state = "Downloading cases for " + ((Court)_court).CourtName + "..."; bwAsync.ReportProgress(Convert.ToInt32(i * (100.0 / _courts.Count)), _state); PacerImportTransaction _transaction = new PacerImportTransaction(); _transaction.CourtID = ((Court)_court).ID; _transaction.CourtName = ((Court)_court).CourtName; _transaction.DischargedCases = !_spec.FiledOnly; if (_spec.StartDate != null) { _transaction.StartDate = (DateTime)_spec.StartDate; } //filed only cases use the LastPacerLoadFileDate else if (_spec.FiledOnly == true) { if (((DateTime)((Court)_court).LastPacerLoadFileDate) > DateTime.MinValue) { _transaction.StartDate = ((DateTime)((Court)_court).LastPacerLoadFileDate).AddDays(1); } else { _transaction.StartDate = DateTime.Now.AddMonths(-1); } } //discharged cases use the LastPacerLoadFileDate else if (_spec.FiledOnly == false) { if (((DateTime)((Court)_court).LastPacerLoadDischargeDate) > DateTime.MinValue) { _transaction.StartDate = ((DateTime)((Court)_court).LastPacerLoadDischargeDate).AddDays(1); } else { _transaction.StartDate = DateTime.Now.AddMonths(-1); } } if (_spec.EndDate != null) { _transaction.EndDate = (DateTime)_spec.EndDate; } else { _transaction.EndDate = DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()); } _transaction.PacerFileFormatID = ((Court)_court).PacerFileFormatID; //check if the transaction overlaps prior periods to avoid extra chanrges, if so throw an error _transaction.CheckForPriorOverlappingDownloads(); _transaction.DownloadNewCases(_spec.GeocodeAddresses); _multipleTransactions.Add(_transaction); // Periodically check if a Cancellation request is pending. If the user // clicks cancel the line _asyncWorker.CancelAsync(); if (bwAsync.CancellationPending) { // Pause for bit to demonstrate that there is time between // "Cancelling..." and "Canceled". // Thread.Sleep(1200); // Set the e.Cancel flag so that the WorkerCompleted event // knows that the process was canceled. e.Cancel = true; return; } } } bwAsync.ReportProgress(100); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected override async Task OnInitializedAsync() => _courts = await CourtService.GetAllAsync();
public CourtController(StvContext db) { _db = db; service = new CourtService(_db); }