public override List<Guid> GetGalleryList( Guid? id, string author, DateTime? initialDateCreated, DateTime? finalDateCreated, string description, bool? isVisible, string keywords, DateTime? initialLastUpdated, DateTime? finalLastUpdated, string lastUpdatedBy, string slug, string title, GalleryStatus? status, int pageSize, int pageIndex, out int totalCount) { totalCount = 0; List<Guid> list = new List<Guid>(); using (TransactionContext context = TransactionContextFactory.EnterContext(TransactionAffinity.NotSupported)) { IDataSource dataSource = DataSourceFactory.GetDataSource("DbGalleryProvider"); IDataCommand cmd = dataSource.GetCommand("GetGalleries"); cmd.Parameters["applicationName"].Value = this.ApplicationName; if (id.HasValue && id.Value != Guid.Empty) cmd.Parameters["id"].Value = id; if (!string.IsNullOrEmpty(author)) cmd.Parameters["author"].Value = author; if (initialDateCreated.HasValue && initialDateCreated.Value != DateTime.MinValue && finalDateCreated.HasValue && finalDateCreated.Value != DateTime.MinValue) { cmd.Parameters["initialDateCreated"].Value = initialDateCreated; cmd.Parameters["finalDateCreated"].Value = finalDateCreated; } if (!string.IsNullOrEmpty(description)) cmd.Parameters["description"].Value = description; if (!(HttpContext.Current != null && HttpContext.Current.User.IsInRole("Administrator")) && isVisible.HasValue) cmd.Parameters["isVisible"].Value = isVisible; if (!string.IsNullOrEmpty(keywords)) cmd.Parameters["keywords"].Value = keywords; if (initialLastUpdated.HasValue && initialLastUpdated.Value != DateTime.MinValue && finalLastUpdated.HasValue && finalLastUpdated.Value != DateTime.MinValue) { cmd.Parameters["initialLastUpdated"].Value = initialLastUpdated; cmd.Parameters["finalLastUpdated"].Value = finalLastUpdated; } if (!string.IsNullOrEmpty(lastUpdatedBy)) cmd.Parameters["lastUpdatedBy"].Value = lastUpdatedBy; if (!string.IsNullOrEmpty(slug)) cmd.Parameters["slug"].Value = slug; if (!string.IsNullOrEmpty(title)) cmd.Parameters["title"].Value = title; if (status.HasValue) cmd.Parameters["status"].Value = status.ToString(); cmd.Parameters["firstIndex"].Value = pageIndex * pageSize; cmd.Parameters["lastIndex"].Value = (pageIndex * pageSize) + pageSize; IDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { list.Add(new Guid(reader["id"].ToString())); } } finally { if (!reader.IsClosed) reader.Close(); } totalCount = Convert.ToInt32(cmd.Parameters["totalCount"].Value); } return list; }
public override List<Guid> GetGalleryList( Guid? id, string author, DateTime? initialDateCreated, DateTime? finalDateCreated, string description, bool? isVisible, string keywords, DateTime? initialLastUpdated, DateTime? finalLastUpdated, string lastUpdatedBy, string slug, string title, GalleryStatus? status, int pageSize, int pageIndex, out int totalCount) { totalCount = 0; List<Guid> list = new List<Guid>(); int? _totalCount = null; GalleryDataContext db = new GalleryDataContext(ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); var query = db.GetGalleries(this.ApplicationName, id, author, initialDateCreated, finalDateCreated, description, isVisible, keywords, initialLastUpdated, finalLastUpdated, lastUpdatedBy, slug, title, status.HasValue ? status.ToString() : null, pageIndex * pageSize, (pageIndex * pageSize) + pageSize, ref _totalCount); foreach (GetGalleriesResult item in query) list.Add(item.ID); if (_totalCount.HasValue) totalCount = _totalCount.Value; return list; }