public TourLog EditTourLog(TourLog currentTourLog, string name, string description, string report, string vehicle, string dateTime, int tourId, decimal distance, decimal totalTime, int rating) { ITourLogDAO tourLogDao = DALFactory.CreateTourLogDAO(); return(tourLogDao.EditTourLog(currentTourLog, name, description, report, vehicle, dateTime, tourId, distance, totalTime, rating)); }
public void TourLogEdit() { Tour tour = _tourDao.AddNewItem("Tour1", "Test Description", "Start", "End", 7, _imagePath); TourLog tourLog = _tourLogDao.AddNewTourLog("testlog", "das ist ein log fuer tour1", "einfache Strecke macht echt spaß", "zu fuß", "01.01.1234", tour.Id, 23, 1, 9); TourLog newTourLog = _tourLogDao.EditTourLog(tourLog, "NewName", "NewDescription", "newReport", "newVehicle", "01.01.1111", tour.Id, 1, 1, 1); Assert.AreEqual("NewName", newTourLog.Name); }
public void Setup() { _tour = new Tour(1, "Tour1", "Test Description", "Start", "End", 7, _imagePath); _tourLog = new TourLog(1, "testlog", "das ist ein log fuer tour1", "einfache Strecke macht echt spaß", "zu fuß", "01.01.1234", 1, 23, 1, 9); _logList = new List <TourLog>() { _tourLog }; }
private void DeleteTourLog(object obj) { _log.Debug("DeleteTourLog klicked"); if (CurrentTourLog != null) { _tourPlannerFactory.DeleteTourLog(CurrentTourLog); TourLogs.Remove(CurrentTourLog); CurrentTourLog = null; } else { _log.Warn("No TourLog selected"); MessageBox.Show("No TourLog selected!", "TourLog Delete", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void AddTourLog(object obj) { if (_mainViewModel.tourListUcViewModel.CurrentItem != null) { _log.Debug("AddTourLog klicked"); Window view = _windowFactoryAddTourLog.GetWindow(_mainViewModel, _mainViewModel.tourListUcViewModel.CurrentItem); view.Show(); CurrentTourLog = null; } else { _log.Warn("No Tour selected"); MessageBox.Show("No Tour selected!", "TourLog Add", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void EditTourLog(object obj) { if (CurrentTourLog != null) { _log.Debug("EditTourLog klicked"); Window view = _windowFactoryEditTourLog.GetWindow(_mainViewModel, _currentTourLog); view.Show(); CurrentTourLog = null; } else { _log.Warn("No TourLog selected"); MessageBox.Show("No TourLog selected!", "TourLog Edit", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void TourLogCreateWithDb() { Tour tour = _tourDao.AddNewItem("Tour1", "Test Description", "Start", "End", 7, _imagePath); TourLog tourLog = _tourLogDao.AddNewTourLog("testlog", "das ist ein log fuer tour1", "einfache Strecke macht echt spaß", "zu fuß", "01.01.1234", tour.Id, 23, 1, 9); Assert.AreEqual("testlog", tourLog.Name); Assert.AreEqual("das ist ein log fuer tour1", tourLog.Description); Assert.AreEqual("einfache Strecke macht echt spaß", tourLog.Report); Assert.AreEqual("zu fuß", tourLog.Vehicle); Assert.AreEqual("01.01.1234", tourLog.DateTime); Assert.AreEqual(tour.Id, tourLog.TourId); Assert.AreEqual(23, tourLog.Distance); Assert.AreEqual(1, tourLog.TotalTime); Assert.AreEqual(9, tourLog.Rating); }
public TourLogEditViewModel(TourLog currentTourLog, Window window, MainViewModel mainViewModel) { this._mainViewModel = mainViewModel; this._window = window; this._tourPlannerFactory = TourPlannerFactory.GetInstance(); this._currentTourLog = currentTourLog; this.TourId = this._currentTourLog.TourId; this.Name = this._currentTourLog.Name; this.Description = this._currentTourLog.Description; this.Report = this._currentTourLog.Report; this.Vehicle = this._currentTourLog.Vehicle; this.DateTime = this._currentTourLog.DateTime; this.Distance = this._currentTourLog.Distance; this.TotalTime = this._currentTourLog.TotalTime; this.Rating = this._currentTourLog.Rating; }
public async Task <TourLog> AddNewTourLog(TourLog log) { DbCommand command = _database.CreateCommand(SQL_INSERT_NEW_TOURLOG); _database.DefineParameter(command, "@Date", DbType.DateTime, log.Date); _database.DefineParameter(command, "@Report", DbType.String, log.Report); _database.DefineParameter(command, "@Distance", DbType.Double, log.Distance); _database.DefineParameter(command, "@Time", DbType.Time, log.Time); _database.DefineParameter(command, "@Rating", DbType.Int32, log.Rating); _database.DefineParameter(command, "@Id", DbType.Guid, log.Id); _database.DefineParameter(command, "@AvgSpeed", DbType.Double, log.AvgSpeed); _database.DefineParameter(command, "@BurnedJoule", DbType.Int32, log.BurnedJoule); _database.DefineParameter(command, "@Difficulty", DbType.Int32, log.Difficulty); _database.DefineParameter(command, "@HeightDelta", DbType.Int32, log.HeightDelta); _database.DefineParameter(command, "@TourId", DbType.Guid, log.Tour.Id); _database.DefineParameter(command, "@MaxSpeed", DbType.Double, log.MaxSpeed); return(await FindById(await _database.ExecuteScalar(command))); }
public TourLog EditTourLog(TourLog currentTourLog, string name, string description, string report, string vehicle, string dateTime, int tourId, decimal distance, decimal totalTime, int rating) { DbCommand editCommand = _database.CreateCommand(SQL_EDIT_TOURLOG); _database.DefineParameter(editCommand, "@name", DbType.String, name); _database.DefineParameter(editCommand, "@description", DbType.String, description); _database.DefineParameter(editCommand, "@report", DbType.String, report); _database.DefineParameter(editCommand, "@vehicle", DbType.String, vehicle); _database.DefineParameter(editCommand, "@datetime", DbType.String, dateTime); _database.DefineParameter(editCommand, "@tourid", DbType.Int32, tourId); _database.DefineParameter(editCommand, "@distance", DbType.Decimal, distance); _database.DefineParameter(editCommand, "@totaltime", DbType.Decimal, totalTime); _database.DefineParameter(editCommand, "@rating", DbType.Int32, rating); _database.DefineParameter(editCommand, "@id", DbType.Int32, currentTourLog.Id); _log.Info("TourLog updated"); return(FindById(_database.ExecuteScalar(editCommand))); }
private void SaveTourLog(object obj) { _log.Debug("Save TourLog klicked"); if (this.Name != null && this.Description != null && this.Report != null && this.Vehicle != null && this.DateTime != null) { _newTourLog = _tourPlannerFactory.AddNewTourLog(this.Name, this.Description, this.Report, this.Vehicle, this.DateTime, this.TourId, this.Distance, this.TotalTime, this.Rating); _mainViewModel.tourInfoUcViewModel.TourLogs.Add(_newTourLog); _log.Info("TourLog could be saved"); } else { _log.Warn("TourLog could not be saved"); MessageBox.Show("TourLog couldn´t be added!", "TourLog Add Error", MessageBoxButton.OK, MessageBoxImage.Error); } _window.Close(); MessageBox.Show("TourLog successfully added!", "TourLog Add", MessageBoxButton.OK, MessageBoxImage.Information); }
private void UpdateTourLog(object obj) { _log.Debug("Update TourLog klicked"); if (this.Name != null && this.Description != null && this.Report != null && this.Vehicle != null && this.DateTime != null) { TourLog tourLog = _tourPlannerFactory.EditTourLog(this._currentTourLog, this.Name, this.Description, this.Report, this.Vehicle, this.DateTime, this.TourId, this.Distance, this.TotalTime, this.Rating); if (tourLog != null) { _mainViewModel.tourInfoUcViewModel.TourLogs.Remove(_currentTourLog); _mainViewModel.tourInfoUcViewModel.TourLogs.Add(tourLog); _log.Info("TourLog could be updated"); } } else { _log.Warn("TourLog could not be updated"); MessageBox.Show("TourLog couldn´t be updated!", "TourLog Edit Error", MessageBoxButton.OK, MessageBoxImage.Error); } _window.Close(); MessageBox.Show("TourLog successfully updated!", "TourLog Edit", MessageBoxButton.OK, MessageBoxImage.Information); }
public System.Windows.Window GetWindow(MainViewModel mainViewModel, TourLog currentTourLog) { throw new System.NotImplementedException(); }
public void DeleteTourLog(TourLog tourLog) { ITourLogDAO tourLogDao = DALFactory.CreateTourLogDAO(); tourLogDao.DeleteTourLog(tourLog); }
public void Setup() { _tourLogDao = new TourLogPostgresDAO(); _tourLog = new TourLog(1, "testlog", "das ist ein log fuer tour1", "einfache Strecke macht echt spaß", "zu fuß", "01.01.1234", 1, 23, 1, 9); }
public TourLogEditWindow(MainViewModel mainViewModel, TourLog currentTourLog) { InitializeComponent(); this.DataContext = new TourLogEditViewModel(currentTourLog, this, mainViewModel); }
public async Task CreateItem(TourLog t) { await _tourLogDAO.AddNewTourLog(t); _log.Debug("Create new TourLog"); }
public async Task DeleteItem(TourLog t) { await _tourLogDAO.DeleteTourLog(t.Id); _log.Debug("Delete Tour with id: " + t.Id); }
public async Task UpdateItem(TourLog t) { await _tourLogDAO.UpdateTourLog(t); }
public System.Windows.Window GetWindow(MainViewModel mainViewModel, TourLog currentTourLog) { TourLogEditWindow view = new TourLogEditWindow(mainViewModel, currentTourLog); return(view); }