Example #1
0
        public void SaveTrip(Trip trip)
        {
            Errors.Clear();

            if (!CheckModel(trip, NullTripErrorMessage, NullTripLogErrorMessage, _logger))
            {
                return;
            }

            try
            {
                if (_persister.IsTripNameUsed(trip.TripName))
                {
                    Errors.Add(string.Format("Trip name {0} is already used, please use another one", trip.TripName));
                    _logger.Warn(string.Format("Trip name {0} is already used, please use another one", trip.TripName));
                    return;
                }

                _logger.Info("Start saving trip");
                var saved = _persister.Save(trip);
                _logger.Info("End saving trip");

                if (!saved)
                {
                    SetErrorAndLog(SaveFail, _logger);
                }
            }
            catch (Exception ex)
            {
                HandleException(ex, _logger);
            }
        }