public static void Save(S_BowlingCenter bowlingCenter)
        {
            logger.Info("Start saving");

            if (bowlingCenter != null)
            {
                try
                {
                    if (BowlingCenterExistById(bowlingCenter.id))
                    {
                        DatabaseConnection databaseconnection = new DatabaseConnection();

                        //open connection
                        if (databaseconnection.OpenConnection())
                        {
                            MySqlConnection sqlConnection = databaseconnection.getConnection();

                            // save the scores
                            if (bowlingCenter.scores != null)
                            {
                                ScoresManager.Save(sqlConnection, bowlingCenter.id, bowlingCenter.scores);
                            }
                            else
                            {
                                logger.Warn("Er zijn geen scores");
                            }

                            //close connection
                            databaseconnection.CloseConnection();
                        }

                        // update the last_syncdate set by the servicehandler
                        Update(bowlingCenter);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("fout bij het opslaan van de scores: " + ex.Message);
                }
            }

            logger.Info("End saving");
        }
Beispiel #2
0
        public static void Save(MySqlConnection sqlConnection, long bowlingCenterId, S_Scores score)
        {
            long?scoreId = null;

            score.bowlingCenterId = bowlingCenterId;

            if (!ScoresManager.ScoresExistByBowlingCenterId(sqlConnection, bowlingCenterId, out scoreId))
            {
                score.id = Insert(sqlConnection, score).Value;
            }
            else
            {
                score.id = ScoresManager.GetScoreById(sqlConnection, scoreId.Value).id;
            }

            foreach (S_Event bowlEvent in score.Events)
            {
                EventManager.Save(sqlConnection, score, bowlEvent);
            }
        }