/// <summary>
        /// Creates an entity.
        /// </summary>
        /// <param name="entity">The entity to create.</param>
        /// <returns>The created entity.</returns>
        /// <exception cref="ArgumentNullException">If any argument is null.</exception>
        /// <exception cref="PersistenceException">If error occurred during access the database persistence.
        /// </exception>
        /// <exception cref="ServiceException">If any other error occurred during the operation.</exception>
        public E.Tag Create(E.Tag entity)
        {
            return(Helper.LoggingWrapper(Logger, () =>
            {
                Helper.CheckNotNull(entity, nameof(entity));

                return Execute((db) =>
                {
                    GetDbSet <E.Tag>(db).InsertOne(entity);

                    return entity;
                }, "creating Tag");
            }, entity));
        }
        /// <summary>
        /// Updates an entity.
        /// </summary>
        /// <param name="entity">The entity to update.</param>
        /// <returns>The updated entity.</returns>
        /// <exception cref="ArgumentNullException">If any argument is null.</exception>
        /// <exception cref="ArgumentException">If entity.Id is not positive.</exception>
        /// <exception cref="EntityNotFoundException">If the entity to update doesn't exist.</exception>
        /// <exception cref="PersistenceException">If error occurred during access the database persistence.
        /// </exception>
        /// <exception cref="ServiceException">If any other error occurred during the operation.</exception>
        public E.Tag Update(E.Tag entity)
        {
            return(Helper.LoggingWrapper(Logger, () =>
            {
                Helper.CheckNotNull(entity, nameof(entity));
                Helper.CheckNotNull(entity.Id, nameof(entity.Id));

                return Execute((db) =>
                {
                    var existing = CheckEntityExists <E.Tag>(entity.Id, db);

                    GetDbSet <E.Tag>(db).ReplaceOne(GetIdFilter(entity.Id), entity);

                    return GetTag(entity.Id, db);
                }, "updating Tag");
            }, entity));
        }