示例#1
0
        public void AddLocation(Location location)
        {
            if (location.Country == null)
            {
                throw new NullReqiuredFieldException("Country");
            }

            addLocation.Parameters["@country"].Value = location.Country;
            if (location.City != null)
            {
                addLocation.Parameters["@city"].Value = location.City;
            }
            if (location.Image != null)
            {
                addLocation.Parameters["@image"].Value = location.Image;
            }

            try
            {
                connection.Open();
                if (addLocation.ExecuteNonQuery() == 0)
                {
                    throw new ZeroRowsExecutedException();
                }
            }
            finally
            {
                Close();
                addLocation.Parameters["@country"].Value = DBNull.Value;
                addLocation.Parameters["@city"].Value    = DBNull.Value;
                addLocation.Parameters["@image"].Value   = DBNull.Value;
            }
            LocationsChanged?.Invoke();
        }
示例#2
0
        public void RemoveLocation(Location location)
        {
            if (location.ID == null)
            {
                throw new NullIdException("Location id is null.");
            }

            removeLocation.Parameters["@ID"].Value = location.ID;

            try
            {
                connection.Open();
                if (removeLocation.ExecuteNonQuery() == 0)
                {
                    throw new ZeroRowsExecutedException();
                }
            }
            finally
            {
                Close();
                removeLocation.Parameters["@ID"].Value = DBNull.Value;
            }
            LocationsChanged?.Invoke();
        }
示例#3
0
 internal static void InvokeLocationsChanged(List <GameLocation> newLocations)
 {
     LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations));
 }
示例#4
0
 public static void InvokeLocationsChanged(List <GameLocation> newLocations)
 {
     LocationsChanged.Invoke(newLocations);
 }