Пример #1
0
        /// <summary>
        /// Fill the <paramref name="emptyCollection"/> with all the galleries in the current application. The return value is the same reference
        /// as the parameter. The template gallery is not included (that is, the one where the gallery ID = <see cref="Int32.MinValue" />.
        /// </summary>
        /// <param name="emptyCollection">An empty <see cref="IGalleryCollection"/> object to populate with the list of galleries in the current
        /// application. This parameter is required because the library that implements this interface does not have
        /// the ability to directly instantiate any object that implements <see cref="IGalleryCollection"/>.</param>
        /// <returns>
        /// Returns an <see cref="IGalleryCollection" /> representing the galleries in the current application. The returned object is the
        /// same object in memory as the <paramref name="emptyCollection"/> parameter.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>
        internal static IGalleryCollection GetGalleries(IGalleryCollection emptyCollection)
        {
            if (emptyCollection == null)
            {
                throw new ArgumentNullException("emptyCollection");
            }

            if (emptyCollection.Count > 0)
            {
                emptyCollection.Clear();
            }

            using (IDataReader dr = GetDataReaderGalleries())
            {
                // SQL:
                //SELECT
                //	GalleryId, Description, DateAdded
                //FROM [gs_Gallery];
                while (dr.Read())
                {
                    IGallery g = emptyCollection.CreateEmptyGalleryInstance();
                    g.GalleryId    = Convert.ToInt32(dr["GalleryId"].ToString().Trim(), CultureInfo.InvariantCulture);
                    g.Description  = Convert.ToString(dr["Description"].ToString().Trim(), CultureInfo.InvariantCulture);
                    g.CreationDate = Convert.ToDateTime(dr["DateAdded"].ToString(), CultureInfo.CurrentCulture);
                    g.Albums       = FlattenGallery(g.GalleryId);

                    emptyCollection.Add(g);
                }
            }

            return(emptyCollection);
        }
        /// <summary>
        /// Fill the <paramref name="emptyCollection"/> with all the galleries in the current application. The return value is the same reference
        /// as the parameter. The template gallery is not included (that is, the one where the gallery ID = <see cref="Int32.MinValue"/>.
        /// </summary>
        /// <param name="emptyCollection">An empty <see cref="IGalleryCollection"/> object to populate with the list of galleries in the current
        /// application. This parameter is required because the library that implements this interface does not have
        /// the ability to directly instantiate any object that implements <see cref="IGalleryCollection"/>.</param>
        /// <returns>
        /// Returns an <see cref="IGalleryCollection"/> representing the galleries in the current application. The returned object is the
        /// same object in memory as the <paramref name="emptyCollection"/> parameter.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>		/// 
        public override IGalleryCollection Gallery_GetGalleries(IGalleryCollection emptyCollection)
        {
            if (emptyCollection == null)
                throw new ArgumentNullException("emptyCollection");

            if (emptyCollection.Count > 0)
            {
                emptyCollection.Clear();
            }

            using (GspContext ctx = new GspContext())
            {
                var galleries = from i in ctx.Galleries where i.GalleryId > int.MinValue select i;

                foreach (GalleryDto gallery in galleries)
                {
                    IGallery g = emptyCollection.CreateEmptyGalleryInstance();

                    g.GalleryId = gallery.GalleryId;
                    g.Description = gallery.Description;
                    g.CreationDate = gallery.DateAdded;
                    g.Albums = FlattenGallery(gallery.GalleryId);

                    emptyCollection.Add(g);
                }
            }

            return emptyCollection;
        }
Пример #3
0
        /// <summary>
        /// Fill the <paramref name="emptyCollection"/> with all the galleries in the current application. The return value is the same reference
        /// as the parameter. The template gallery is not included (that is, the one where the gallery ID = <see cref="Int32.MinValue" />.
        /// </summary>
        /// <param name="emptyCollection">An empty <see cref="IGalleryCollection"/> object to populate with the list of galleries in the current 
        /// application. This parameter is required because the library that implements this interface does not have
        /// the ability to directly instantiate any object that implements <see cref="IGalleryCollection"/>.</param>
        /// <returns>
        /// Returns an <see cref="IGalleryCollection" /> representing the galleries in the current application. The returned object is the
        /// same object in memory as the <paramref name="emptyCollection"/> parameter.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>
        internal static IGalleryCollection GetGalleries(IGalleryCollection emptyCollection)
        {
            if (emptyCollection == null)
                throw new ArgumentNullException("emptyCollection");

            if (emptyCollection.Count > 0)
            {
                emptyCollection.Clear();
            }

            using (IDataReader dr = GetDataReaderGalleries())
            {
                // SQL:
                //SELECT
                //	GalleryId, Description, DateAdded
                //FROM [gs_Gallery];
                while (dr.Read())
                {
                    IGallery g = emptyCollection.CreateEmptyGalleryInstance();
                    g.GalleryId = Convert.ToInt32(dr["GalleryId"].ToString().Trim(), CultureInfo.InvariantCulture);
                    g.Description = Convert.ToString(dr["Description"].ToString().Trim(), CultureInfo.InvariantCulture);
                    g.CreationDate = Convert.ToDateTime(dr["DateAdded"].ToString(), CultureInfo.CurrentCulture);
                    g.Albums = FlattenGallery(g.GalleryId);

                    emptyCollection.Add(g);
                }
            }

            return emptyCollection;
        }
Пример #4
0
		/// <summary>
		/// Fill the <paramref name="emptyCollection"/> with all the galleries in the current application. The return value is the same reference
		/// as the parameter. The template gallery is not included (that is, the one where <see cref="GalleryDto.IsTemplate" /> = <c>true</c>).
		/// </summary>
		/// <param name="emptyCollection">An empty <see cref="IGalleryCollection"/> object to populate with the list of galleries in the current
		/// application. This parameter is required because the library that implements this interface does not have
		/// the ability to directly instantiate any object that implements <see cref="IGalleryCollection"/>.</param>
		/// <returns>
		/// Returns an <see cref="IGalleryCollection"/> representing the galleries in the current application. The returned object is the
		/// same object in memory as the <paramref name="emptyCollection"/> parameter.
		/// </returns>
		/// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>		/// 
		private static IGalleryCollection LoadGalleries(IGalleryCollection emptyCollection)
		{
			if (emptyCollection == null)
				throw new ArgumentNullException("emptyCollection");

			if (emptyCollection.Count > 0)
			{
				emptyCollection.Clear();
			}

			using (var repo = new GalleryRepository())
			{
				//var galleries = from i in ctx.Galleries where i.GalleryId > int.MinValue select i;
				var galleries = repo.Where(g => !g.IsTemplate);

				foreach (GalleryDto gallery in galleries)
				{
					IGallery g = emptyCollection.CreateEmptyGalleryInstance();

					g.GalleryId = gallery.GalleryId;
					g.Description = gallery.Description;
					g.CreationDate = gallery.DateAdded;
					g.Albums = FlattenGallery(gallery.GalleryId);

					emptyCollection.Add(g);
				}
			}

			return emptyCollection;
		}