예제 #1
0
        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;
        }
예제 #2
0
        public async Task<AddUpdatePathStatus> AddAsync(Path path)
        {
            if (await IsExistAsync(path.SourceCity, path.DestinationCity))
                return AddUpdatePathStatus.DuplicateSourceAndDestination;

            _paths.Add(path);
            return AddUpdatePathStatus.Success;
        }
예제 #3
0
 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;
 }
예제 #4
0
        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();
        }
예제 #5
0
 private void pathCombo_SelectedIndexChanged(object sender, EventArgs e)
 {
     var ix = pathCombo.SelectedIndex;
     if (ix >= 0) Path = _pathList[ix];
 }
예제 #6
0
 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;
 }
예제 #7
0
 private void pathBrowseButton_Click(object sender, EventArgs e)
 {
     var res = _showListForCities.ShowSelectionDialog(_result.Path);
     if (res != null) Path = res;
 }
예제 #8
0
 public void Inactive(Path path)
     => path.ActiveState = false;
예제 #9
0
 public void Activate(Path path)
     => path.ActiveState = true;