Пример #1
0
        public void SaveNewLocation(Location newLocation)
        {
            var existingLocation = _locationRepository.GetLocationById(newLocation.ID);

            if (existingLocation == null)
            {
                _locationRepository.SaveNewLocation(newLocation);
                _logger.Trace(LoggerHelper.ExecutedFunctionMessage(LoggerHelper.VOID_TYPE, newLocation));
                _logger.Info("New location successfully added: " + newLocation.Name + "/" + newLocation.ID);
            }
            else
            {
                LocationExistsException exn = new LocationExistsException();
                _logger.Trace(LoggerHelper.ExecutedFunctionMessage(exn, newLocation));
                throw exn;
            }
        }
Пример #2
0
        public void EditLocation(Location originalLocation, Location editLocation)
        {
            if (editLocation.Name != originalLocation.Name)
            {
                bool exists = _locationRepository.GetLocationByName(editLocation.Name) != null;
                if (exists)
                {
                    LocationExistsException exn = new LocationExistsException();

                    _logger.Trace(LoggerHelper.ExecutedFunctionMessage(exn, originalLocation, editLocation));

                    throw exn;
                }
            }

            editLocation.ID = originalLocation.ID;

            _locationRepository.UpdateLocation(editLocation);
            _logger.Trace(LoggerHelper.ExecutedFunctionMessage(LoggerHelper.VOID_TYPE, originalLocation, editLocation));
            _logger.Info(string.Format("Location {0} successfully editted", originalLocation.ID));
        }