/// <summary>
        /// This method forward the call to the Update method with adding the single method number inside a single item int list
        /// </summary>
        /// <param name="type">Type of the mining entity</param>
        /// <param name="methodList">List of methods to be executed</param>
        /// <param name="miningState">Mining state to monitor the progress of the mining</param>
        public void Update(MiningEntityType type, int methodNumber, MiningState miningState)
        {
            var list = new List <int>()
            {
                methodNumber
            };

            Update(type, list, miningState);
        }
        public void UpdateGenres(int methodNumber, MiningState miningState = null)
        {
            var list = new List <int>()
            {
                methodNumber
            };

            UpdateGenres(list, miningState);
        }
        /// <summary>
        /// This method calls right update method based on the mining entity type
        /// </summary>
        /// <param name="type">Type of the mining entity</param>
        /// <param name="methodList">List of methods to be executed</param>
        /// <param name="miningState">Mining state to monitor the progress of the mining</param>
        public void Update(MiningEntityType type, List <int> methodList, MiningState miningState)
        {
            switch (type)
            {
            case MiningEntityType.Books:
                UpdateBooks(methodList, miningState);
                break;

            case MiningEntityType.Authors:
                UpdateAuthors(methodList, miningState);
                break;

            case MiningEntityType.Genres:
                UpdateGenres(methodList, miningState);
                break;

            case MiningEntityType.Characters:
                UpdateCharacters(methodList, miningState);
                break;

            default:
                throw new NotSupportedException(type.ToString());
            }
        }
        /// <summary>
        /// Method which takes IEnumerable with the data and calls the assigned line action on every line of the data.
        /// The data needs to fit inside the line action.
        /// This method is meant to be used when mining from web interface
        /// </summary>
        /// <param name="data">Enumerable with the data lines</param>
        /// <param name="lineAction">Action which will be executed on each line</param>
        /// <param name="miningState">Mining state of the operation from the MiningProxySingleton used to monitor the data mining</param>
        protected void UpdateDatabase <T>(IEnumerable <T> data, LineAction <T> lineAction, MiningState miningState)
        {
            // fall back for deprecated commandline mining
            if (miningState == null)
            {
                UpdateDatabase <T>(data, lineAction);
                return;
            }

            try
            {
                // set the mining state
                miningState.CurrentState = MiningStateType.RunningQueryingEndpoint;
                var listData = data.ToList();
                miningState.CurrentState = MiningStateType.Running;
                var currentPosition = 0;
                using (var db = new BookRecommenderContext())
                {
                    // proccess each line using the line action and log changes to the mining state
                    foreach (var line in listData)
                    {
                        lineAction(line, db);
                        currentPosition++;
                        miningState.Message = String.Format("{0}/{1}",
                                                            currentPosition, listData.Count);
                    }
                    miningState.CurrentState = MiningStateType.RunningSavingToDatabase;
                    db.SaveChanges();
                    miningState.CurrentState = MiningStateType.Completed;
                    miningState.Message      = DateTime.Now.ToString();
                }
            }
            catch (Exception ex)
            {
                // If something went wrong, wait 10 sec and then try again
                miningState.CurrentState = MiningStateType.Error;
                miningState.Message      = ex.Message;
            }
        }
 /// <summary>
 /// Method which call the right updating the database with correct action and data pairs
 /// </summary>
 /// <param name="methodList">List of methods to be executed</param>
 /// <param name="miningState">Mining state to monitor the progress of the mining</param>
 public abstract void UpdateGenres(List <int> methodList, MiningState miningState = null);
 /// <summary>
 /// Method which call the right updating the database with correct action and data pairs
 /// </summary>
 /// <param name="methodList">List of methods to be executed</param>
 /// <param name="miningState">Mining state to monitor the progress of the mining</param>
 public abstract void UpdateCharacters(List <int> methodList, MiningState miningState = null);