public async Task<AddUpdatePathStatus> UpdateAsync(Path path) { var old = await FindBySourceAndDestinationAsync(path.SourceCity, path.DestinationCity); if (old?.Id != path.Id) return AddUpdatePathStatus.DuplicateSourceAndDestination; return AddUpdatePathStatus.Success; }
public async Task<AddUpdatePathStatus> AddAsync(Path path) { if (await IsExistAsync(path.SourceCity, path.DestinationCity)) return AddUpdatePathStatus.DuplicateSourceAndDestination; _paths.Add(path); return AddUpdatePathStatus.Success; }
protected override DataGridViewRow FillRow(Path entity, DataGridViewRow rowToAdd) { rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.Id}); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.SourceCity}); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.DestinationCity}); rowToAdd.Cells.Add(new DataGridViewTextBoxCell {Value = entity.SuggestedRentMoney.ToString("C0")}); if (!entity.ActiveState) rowToAdd.DefaultCellStyle.BackColor = _inactiveColor; return rowToAdd; }
protected override void OnSaveButtonClicked() { var entity = new Path { SourceCity = sourceCityBox.Text.Trim(), DestinationCity = destinationCistyBox.Text.Trim(), SuggestedRentMoney = rentBox.Value }; if (!Validation(entity)) return; var old = _repository.FirstOrDefault(x => x.Id == _result.Id); if (old == null) { entity.ActiveState = true; _repository.Add(entity); } else { old.SourceCity = entity.SourceCity; old.DestinationCity = entity.DestinationCity; old.SuggestedRentMoney = entity.SuggestedRentMoney; } SaveAndExit(); }
private void pathCombo_SelectedIndexChanged(object sender, EventArgs e) { var ix = pathCombo.SelectedIndex; if (ix >= 0) Path = _pathList[ix]; }
private void pathCombo_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Enter) return; int id; if (!int.TryParse(pathCombo.Text, out id)) return; var p = _pathList.FirstOrDefault(x => x.Id == id); if (p != null) Path = p; }
private void pathBrowseButton_Click(object sender, EventArgs e) { var res = _showListForCities.ShowSelectionDialog(_result.Path); if (res != null) Path = res; }
public void Inactive(Path path) => path.ActiveState = false;
public void Activate(Path path) => path.ActiveState = true;