コード例 #1
0
ファイル: Usr.cs プロジェクト: davelondon/dontstayin
		private static Query EventsWithTicketsQuery(Usr usr, Utilities.DateRange dateRange, int pageNumber, int recordsPerPage)
		{
			// Date range for all
			DateTime startDateRange = new DateTime(2006, 7, 1);
			DateTime endDateRange = DateTime.MaxValue;

			if (dateRange.Equals(Utilities.DateRange.Current))
				startDateRange = DateTime.Today.AddMonths(-1);
			else if (dateRange.Equals(Utilities.DateRange.Old))
				endDateRange = DateTime.Today.AddMonths(-1);

			Query eventWithTicketsQuery = new Query(new And(new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, startDateRange),
															new Q(Event.Columns.DateTime, QueryOperator.LessThan, endDateRange),
															new Q(Ticket.Columns.BuyerUsrK, usr.K),
															new Q(Ticket.Columns.Quantity, QueryOperator.GreaterThan, 0),
															new Q(Ticket.Columns.Enabled, true)));
			eventWithTicketsQuery.Columns = new ColumnSet(Event.Columns.K,
															Event.Columns.SpotterRequest,
															Event.Columns.IsTicketsAvailable,
															Event.Columns.UrlFragment,
															Event.Columns.VenueK,
															Event.Columns.DateTime,
															Event.Columns.Pic,
															Event.Columns.StartTime,
															Event.Columns.LivePhotos,
															Event.Columns.Name,
															Event.Columns.MusicTypesString,
															Event.Columns.VenueK
															);
			eventWithTicketsQuery.Distinct = true;
			eventWithTicketsQuery.DistinctColumn = Event.Columns.K;
			
			eventWithTicketsQuery.TableElement = Event.EventTicketJoin;

			if (pageNumber > 0 && recordsPerPage > 0)
			{
				eventWithTicketsQuery.Paging.RecordsPerPage = recordsPerPage;
				eventWithTicketsQuery.Paging.RequestedPage = pageNumber;
				eventWithTicketsQuery.TopRecords = (pageNumber * recordsPerPage) + 1;
			}

			eventWithTicketsQuery.OrderBy = new OrderBy(new OrderBy(Event.Columns.DateTime, OrderBy.OrderDirection.Descending), new OrderBy(Event.Columns.Donated), new OrderBy(Event.Columns.Name));

			return eventWithTicketsQuery;
		}
コード例 #2
0
ファイル: Usr.cs プロジェクト: davelondon/dontstayin
		public TicketSet Tickets(Utilities.DateRange dateRange, int pageNumber, int recordsPerPage)
		{
			// Date range for all
			DateTime startDateRange = new DateTime(2006, 7, 1);
			DateTime endDateRange = DateTime.MaxValue;

			if (dateRange.Equals(Utilities.DateRange.Current))
				startDateRange = DateTime.Today.AddMonths(-1);
			else if (dateRange.Equals(Utilities.DateRange.Old))
				endDateRange = DateTime.Today.AddMonths(-1);

			Query ticketQuery = new Query(new And(new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, startDateRange),
												  new Q(Event.Columns.DateTime, QueryOperator.LessThan, endDateRange),
												  new Q(Ticket.Columns.BuyerUsrK, this.K),
												  new Q(Ticket.Columns.Enabled, true)));
			ticketQuery.Columns = new ColumnSet(Ticket.Columns.K, Ticket.Columns.Cancelled, Ticket.Columns.CardNumberEnd, Ticket.Columns.Quantity, Ticket.Columns.EventK, Ticket.Columns.Feedback, Ticket.Columns.FeedbackNote);
			//ticketQuery.Distinct = true;
			//ticketQuery.DistinctColumn = Ticket.Columns.K;
			if (pageNumber > 0 && recordsPerPage > 0)
			{
				ticketQuery.Paging.RecordsPerPage = recordsPerPage;
				ticketQuery.Paging.RequestedPage = pageNumber;
				ticketQuery.TopRecords = (pageNumber * recordsPerPage) + 1;
			}
			ticketQuery.ExtraSelectElements.Add("TicketRunName", "[TicketRun].[Name]");
			ticketQuery.ExtraSelectElements.Add("TicketRunDescription", "[TicketRun].[Description]");
			ticketQuery.ExtraSelectElements.Add("TicketRunPrice", "[TicketRun].[Price]");
			ticketQuery.ExtraSelectElements.Add("TicketRunK", "[TicketRun].[K]");

			ticketQuery.OrderBy = new OrderBy(new OrderBy(Event.Columns.DateTime, OrderBy.OrderDirection.Descending), new OrderBy(TicketRun.Columns.Price));

			ticketQuery.TableElement = new Join(new Join(Ticket.Columns.EventK, Event.Columns.K), TicketRun.Columns.K, Ticket.Columns.TicketRunK);


			return new TicketSet(ticketQuery);
		}