Esempio n. 1
0
        /// <summary>
        /// Add a genre to list and db.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="type"></param>
        private void AddGenre(string text)
        {
            text = text.Trim();

            if (!this.NameIsValid(text, this.list_Genres.Items))
            {
                this.ShowInvalidMessage();

                return;
            }

            Entity.Genre genre = new Entity.Genre()
            {
                Name = text
            };

            // In order, add to object list, display list and DB
            this.genres.Add(genre);
            this.list_Genres.Items.Add(genre.Name);

            Repository.Genre.Instance.Add(genre);
        }
Esempio n. 2
0
        /// <summary>
        /// Modify an existing genre.
        /// </summary>
        /// <param name="text"></param>
        private void EditGenre(string text)
        {
            text = text.Trim();

            if (!this.NameIsValid(text, this.list_Genres.Items))
            {
                this.ShowInvalidMessage();

                return;
            }

            if (this.list_Genres.SelectedIndex >= 0)
            {
                Entity.Genre genre = this.genres[this.list_Genres.SelectedIndex];
                genre.Name = text;

                Repository.Genre.Instance.Update(genre);
            }

            this.list_Genres.Items.Clear();
            this.LoadGenres();
        }
Esempio n. 3
0
 /// <summary>
 /// Update the whole entity.
 /// </summary>
 /// <param name="entity"></param>
 public void Update(Entity.Genre entity)
 {
     App.db.Update(Entity.Genre.TABLE, entity.Id, this.table.GetKeysAndValues(entity));
 }
Esempio n. 4
0
        public void CreateTable(Entity.Genre genre)
        {
            string exp = this.table.GetExpression(genre);

            App.db.CreateTable(exp);
        }
Esempio n. 5
0
        /*
         * ======================================
         * Action
         * ======================================
         */

        #region Action

        /// <summary>
        /// Add an entity in database.
        /// </summary>
        /// <param name="episode"></param>
        /// <returns>created entity ID</returns>
        public int Add(Entity.Genre entity)
        {
            App.db.Insert(Entity.Genre.TABLE, this.table.GetKeysAndValues(entity));

            return(App.db.LastId(Entity.Genre.TABLE));
        }