public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } AddEntry = await _context.AddEntry.FindAsync(id); //Updates minutes in UserMinutes var userMin = _context.UserMinutes.Find(AddEntry.UserID); userMin.Minutes -= AddEntry.Minutes; _context.UserMinutes.Update(userMin); //Generate Eventlog var user = await _userManager.GetUserAsync(User); var eventLog = "Removed " + AddEntry.Minutes + " Minutes"; EventLog log = new EventLog { Date = DateTime.Now, UserName = user.UserName, Event = eventLog }; _context.EventLog.Add(log); if (AddEntry != null) { _context.AddEntry.Remove(AddEntry); await _context.SaveChangesAsync(); } return(RedirectToPage("/Index")); }
public void MergeFrom(JournalEntry other) { if (other == null) { return; } if (other.addEntry_ != null) { if (addEntry_ == null) { addEntry_ = new global::POGOProtos.Data.AssetCache.JournalAddEntry(); } AddEntry.MergeFrom(other.AddEntry); } if (other.readEntry_ != null) { if (readEntry_ == null) { readEntry_ = new global::POGOProtos.Data.AssetCache.JournalReadEntry(); } ReadEntry.MergeFrom(other.ReadEntry); } if (other.removeEntry_ != null) { if (removeEntry_ == null) { removeEntry_ = new global::POGOProtos.Data.AssetCache.JournalRemoveEntry(); } RemoveEntry.MergeFrom(other.RemoveEntry); } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public async Task Should_not_add_report_when_being_blocked() { var cmd = new AddEntry { DomainName = "report4.coderr.io", ApplicationIds = new[] { 1 }, IpAddresses = new[] { "1.2.3.4" } }; await _apiClient.SendAsync(cmd); await GetEntry(x => x.DomainName == cmd.DomainName); IncidentWrapper entry = null; try { entry = await _applicationClient.CreateIncidentWithoutSignature(); } catch { // should throw since the report should be ignored. } entry.Should().BeNull(); }
private void lv_Assignments_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (this.SelectedAssignment != null) { CheckForSubtasksForAssignmentAndCreateIfNecessary(this.SelectedAssignment.Id); var addEntryDialog = new AddEntry(this.SelectedAssignment.ProjectId, this.SelectedAssignment.Id); addEntryDialog.ShowDialog(); } }
private void AddEdit_Load(object sender, EventArgs e) { table = AddEntry.Table(); AddEntryDgv.DataSource = table; AddEntryDgv.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; AddEntryDgv.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; Alpha.TableNameSwitcher(); NextMeetingDateTxt.Text = Alpha.CurrentDate.ToString(); }
/// <summary> /// Add name and number to a specific phone book /// </summary> /// <param name="entry">Phone Book name and number entry/param> /// <returns>Object representing the added entry/returns> public AddEntry addEntry(AddEntry entry) { var filter = Builders <PhoneBook> .Filter.Eq("name", entry.phoneBookName); var update = Builders <PhoneBook> .Update.Push("entries", entry.entry); _phoneBook.FindOneAndUpdate(filter, update); return(entry); }
public void AddPathEntry(string entry) { // string addedEntries = ""; try { // var oldPath = Environment.GetEnvironmentVariable("path", EnvironmentVariableTarget.Machine); var oldPath = CurrentPathText; // var newEntry = entry; if (entry == string.Empty || oldPath.Contains(entry) || !Directory.Exists(entry) ) { var msg = string.Format("[{0}]\nThe Entry exist in the Path or not valid one ", entry); var result = MessageBox.Show(msg, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } var newPath = oldPath + ";" + entry; //update path // MessageBox.Show(newPath); // var msg = "The new path is " + Convert.ToString(size1) + Environment.NewLine; var msg2 = "Are you sure to add the new Entry to path"; var result2 = MessageBox.Show(msg2, "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result2 == DialogResult.Cancel) { return; } Cursor.Current = Cursors.WaitCursor; // Environment.SetEnvironmentVariable("path", newPath, EnvironmentVariableTarget.Machine); SaveProgramPath(newPath); CurrentPathText = newPath; Init(); _logger.Info("Add: {0}", entry); //should init variables //OnCollectionChanged(NotifyCollectionChangedAction.Reset); // OnAddEntry(null); AddEntry.Raise(this, null); MessageBox.Show("Sucess Updating the Path", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); _logger.Error("Error in Add Entry: " + ex.Message); } finally { Cursor.Current = Cursors.Default; } }
public async Task Should_be_able_to_add_a_whitelist_entry_with_just_domainName() { var cmd = new AddEntry { DomainName = "report.coderr.io" }; await _apiClient.SendAsync(cmd); var actual = await GetEntry(x => x.DomainName == cmd.DomainName); actual.IpAddresses.First().Address.Should().Be("40.69.200.124"); }
public async Task Should_be_able_to_add_a_whitelist_entry_with_manual_ip() { var cmd = new AddEntry { DomainName = "report2.coderr.io", IpAddresses = new[] { "1.2.3.4" } }; await _apiClient.SendAsync(cmd); var actual = await GetEntry(x => x.DomainName == cmd.DomainName); actual.IpAddresses.Single().Address.Should().Be("1.2.3.4"); }
public async Task Should_be_able_to_add_a_whitelist_entry_with_ips_and_apps() { var cmd = new AddEntry { DomainName = "report3.coderr.io", ApplicationIds = new[] { 1 }, IpAddresses = new[] { "1.2.3.4" } }; await _apiClient.SendAsync(cmd); var actual = await GetEntry(x => x.DomainName == cmd.DomainName); actual.Applications.Single().ApplicationId.Should().Be(1); }
public async Task Should_be_able_to_add_a_whitelist_entry_with_apps() { var cmd = new AddEntry { DomainName = "app.coderr.io", ApplicationIds = new[] { 1 } }; await _apiClient.SendAsync(cmd); var actual = await GetEntry(x => x.DomainName == cmd.DomainName && x.IpAddresses.Any()); actual.Applications.Single().ApplicationId.Should().Be(1); actual.IpAddresses.First().Address.Should().Be("40.69.200.124"); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } AddEntry = await _context.AddEntry.FirstOrDefaultAsync(m => m.ID == id); if (AddEntry == null) { return(NotFound()); } return(Page()); }
public async Task Should_add_report_when_ip_is_allowed() { var cmd = new AddEntry { DomainName = "report5.coderr.io", ApplicationIds = new[] { _applicationClient.ApplicationId }, IpAddresses = new[] { "::1" } }; await _apiClient.SendAsync(cmd); await GetEntry(x => x.DomainName == cmd.DomainName); var entry = await _applicationClient.CreateIncidentWithoutSignature(); entry.Should().NotBeNull(); }
public async Task <ActionResult <EntryDto> > AddEntry(AddEntry entry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; if (userId is null) { return(BadRequest(new ErrorDto("No user data!"))); } return(await _entryService.AddAsync(entry.Text, userId)); }
private void Client_OnMessage(object sender, MessageEventArgs e) { var code = e.Data.Split('|')[0]; var data = e.Data.Split('|')[1]; switch (code) { case "USERS": GetAllUsers(data); break; case "MESSAGE": var add = new AddEntry(AddChatEntry); panelChat.Invoke(add, new object[] { data }); break; } }
public async Task Should_be_able_to_delete_an_entry() { var cmd1 = new AddEntry { DomainName = "report4.coderr.io", ApplicationIds = new[] { 1 }, IpAddresses = new[] { "1.2.3.4" } }; await _apiClient.SendAsync(cmd1); var entry = await GetEntry(x => x.DomainName == cmd1.DomainName); var cmd = new RemoveEntry { Id = entry.Id }; await _apiClient.SendAsync(cmd); await GetEmptyList(); }
public async Task Should_be_able_to_update_an_entry() { var cmd1 = new AddEntry { DomainName = "report4.coderr.io", ApplicationIds = new[] { 1 }, IpAddresses = new[] { "1.2.3.4" } }; await _apiClient.SendAsync(cmd1); var entry = await GetEntry(x => x.DomainName == cmd1.DomainName); var cmd = new EditEntry { Id = entry.Id, IpAddresses = new[] { "2.3.4.5" } }; await _apiClient.SendAsync(cmd); await GetEntry(x => x.DomainName == cmd1.DomainName && x.IpAddresses[0].Address == cmd.IpAddresses[0]); }
public async Task Should_ban_non_matching_ip() { var cmd = new AddEntry { DomainName = "report4.coderr.io", }; await _apiClient.SendAsync(cmd); await GetEntry(x => x.DomainName == cmd.DomainName); try { await _applicationClient.CreateIncidentWithoutSignature(); } catch { // should throw since the report should be ignored. } await GetEntry(x => x.IpAddresses.Any(y => y.Address == "::1")); }
public override int GetHashCode() { int hash = 1; if (addEntry_ != null) { hash ^= AddEntry.GetHashCode(); } if (readEntry_ != null) { hash ^= ReadEntry.GetHashCode(); } if (removeEntry_ != null) { hash ^= RemoveEntry.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task <IActionResult> OnPostAddEntry(AddEntry model) { if (!model.VerifiedEntryType.HasValue) { TempData["error"] += $"You must specify a {nameof(model.VerifiedEntryType)}"; return(RedirectToPage("Verified")); } if (model.VerifiedEntryType == VerifiedEntryType.FootballerInPL && !model.PLPlayer.HasValue) { TempData["error"] += $"Cannot add {nameof(VerifiedEntryType.FootballerInPL)} without {nameof(model.PLPlayer)}"; return(RedirectToPage("Verified")); } _logger.LogInformation("Adding new entry: {entryId}", model.EntryId); await _repo.Insert(new VerifiedEntry( model.EntryId, model.FullName, model.EntryTeamName, model.VerifiedEntryType.Value, model.Alias, model.Description)); TempData["msg"] += $"Entry {model.EntryId} added!"; await _mediator.Publish(new UpdateEntryStats(model.EntryId)); if (model.PLPlayer.HasValue) { var settings = await _settings.GetGlobalSettings(); var gameweek = settings.Gameweeks.GetCurrentGameweek(); await _mediator.Publish(new ConnectEntryToPLPlayer(model.EntryId, model.PLPlayer.Value, gameweek?.Id)); } await _mediator.Publish(new IndexEntry(model.EntryId)); return(RedirectToPage("Verified")); }
public static void Menu(string version) { do { Console.Clear(); Console.Title = "Yellow Pointer v" + version; if (Utility.AdminMode) { Console.Title += " (Admin Mode)"; } var title = "===Yellow Pointer Main Menu, v" + version; if (Utility.AdminMode) { title += " (Admin Mode)"; } Console.WriteLine(title + "==="); Console.WriteLine("1. Search Database"); Console.WriteLine("2. Add Database Entries"); Console.WriteLine("3. Edit Database Entries"); Console.WriteLine("4. Launch Commands Web Page"); Console.WriteLine("5. Settings"); Console.WriteLine("6. Help"); Console.WriteLine("7. Exit"); if (Utility.AdminMode) { Console.WriteLine("8. Admin Tools"); } var input = Console.ReadLine(); if (input == null) { continue; } var lower = input.ToLower(); if (lower == "exit") { Environment.Exit(0); } int.TryParse(input, out var num); switch (num) { case 1: Search.Menu(); break; case 2: Utility.BackUpDatabase(); AddEntry.Menu(); break; case 3: Utility.BackUpDatabase(); EditEntry.Menu(); break; case 4: if (Utility.DetermineOs() == "macos") { Process.Start("open", WebPath + "index.html"); } else { Process.Start(WebPath + "index.html"); } break; case 5: Settings.Menu(); break; case 6: Help.DisplayHelp(); break; case 7: Environment.Exit(0); break; case 8: if (!Utility.AdminMode) { Console.WriteLine("Invalid input"); break; } AdminTools.Menu(); break; default: Console.WriteLine("Invalid input"); break; } } while (true); }
public static void Update() { if (!DownloadFormsIndex()) { return; } var filings = ParseFormsIndex(); var amendments = Get10KAmendments(); if (filings.Count == 0) //If there's no filings relevant to updating the database { Console.WriteLine("No forms have been filed at this time"); return; } var tickersToUpdate = EndingFiscalYearCompanies(); //Queue of companies to DL from Morningstar //var queue = tickersToUpdate.Where(x => filings.Contains(x)).ToList(); var queue = filings.Where(filing => tickersToUpdate.Contains(filing)).ToList(); Console.Write("There "); var count = queue.Count + amendments.Count; Console.Write(count == 1 ? "is " : "are "); Console.Write(count + " ticker"); if (count > 1) { Console.Write("s"); } Console.WriteLine(" in the update queue."); Console.WriteLine("Updating database, please wait..."); //Run add entry command AddEntry.Init(); using (var db = new LiteDatabase(Database)) { var dbKeyRatio = db.GetCollection <KeyRatio>("keyRatios"); foreach (var q in queue) { var r = dbKeyRatio.FindOne(Query.Contains("Cik", q)); if (r == null) { Utility.WriteToLog(q + ": Could not find in database", ErrorLog); } else { AddEntry.Add(r.Ticker, false); } } foreach (var amendment in amendments) { var r = dbKeyRatio.FindOne(Query.Contains("Cik", amendment)); if (r != null) { AddEntry.Add(r.Ticker, true); } } } Utility.PurgeTempDirectory(); Console.WriteLine("Database updated!"); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); /* * Console.WriteLine("Verifying integrity..."); * var list = VerifyFiscalIntegrity(); * if (list.Count != 0) * { * var message = "The following ticker(s) lack financial info:\n"; * using (var db = new LiteDatabase(Database)) * { * var dbKeyRatio = db.GetCollection<KeyRatio>("keyRatios"); * message = list * .Select(l => dbKeyRatio.FindOne(Query.EQ("Cik", l))) * .Aggregate(message, (current, r) => current + r.Ticker + "\n"); * } * Utility.WriteToLog(message, "FiscalIntegrityAnalysisError.txt"); * Console.WriteLine("Some companies are missing information."); * Console.WriteLine("More information written to desktop"); * } * else * { * Console.WriteLine("Database integrity analysis successful!"); * } */ }
public async Task <EntryDto> Add(AddEntry entry) { return(await _entryApi.Add(entry)); }
public ActionResult <PhoneBookEntry> addEntry(AddEntry entry) { _phoneBookService.addEntry(entry); return(Ok(entry)); }
public void AddEntryClick(object sender, RoutedEventArgs s) { var AddEntryWindow = new AddEntry(db, roles, _username, this); AddEntryWindow.Show(); }