public static Gig Create(Core core, Musician owner, Tour tour, long time, ushort timezone, string city, string venue, string gigAbstract, bool allAges) { if (core == null) { throw new NullCoreException(); } // TODO: fix this Item item = Item.Create(core, typeof(Gig), new FieldValuePair("musician_id", owner.Id), new FieldValuePair("tour_id", ((tour != null) ? tour.Id : 0)), new FieldValuePair("gig_time_ut", time), new FieldValuePair("gig_time_zone", timezone), new FieldValuePair("gig_city", city), new FieldValuePair("gig_venue", venue), new FieldValuePair("gig_abstract", gigAbstract), new FieldValuePair("gig_all_ages", allAges)); Gig gig = (Gig)item; if (gig.TourId > 0) { UpdateQuery uQuery = new UpdateQuery(typeof(Tour)); uQuery.AddField("tour_gigs", new QueryOperation("tour_gigs", QueryOperations.Addition, "1")); uQuery.AddCondition("tour_id", gig.TourId); } return gig; }
void AccountTourManage_Edit(object sender, ModuleModeEventArgs e) { SetTemplate("account_tour_edit"); Tour tour = null; /* */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* */ SelectBox yearSelectBox = new SelectBox("year"); /* */ TextBox abstractTextBox = new TextBox("abstract"); abstractTextBox.Lines = 5; abstractTextBox.IsFormatted = true; for (int i = 1980; i < DateTime.UtcNow.Year + 5; i++) { yearSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } switch (e.Mode) { case "add": yearSelectBox.SelectedKey = core.Tz.Now.Year.ToString(); break; case "edit": long tourId = core.Functions.FormLong("id", core.Functions.RequestLong("id", 0)); try { tour = new Tour(core, tourId); } catch (InvalidTourException) { return; } titleTextBox.Value = tour.Title; abstractTextBox.Value = tour.TourAbstract; if (yearSelectBox.ContainsKey(tour.StartYear.ToString())) { yearSelectBox.SelectedKey = tour.StartYear.ToString(); } if (core.Http.Form["title"] != null) { titleTextBox.Value = core.Http.Form["title"]; } yearSelectBox.SelectedKey = core.Functions.FormShort("year", short.Parse(yearSelectBox.SelectedKey)).ToString(); template.Parse("S_ID", tour.Id.ToString()); template.Parse("EDIT", "TRUE"); break; } template.Parse("S_TITLE", titleTextBox); template.Parse("S_ABSTRACT", abstractTextBox); template.Parse("S_YEAR", yearSelectBox); SaveItemMode(AccountTourManage_EditSave, tour); }
public Gig(Core core, Tour tour, DataRow gigRow) : base(core) { this.tour = tour; ItemLoad += new ItemLoadHandler(Gig_ItemLoad); try { loadItemInfo(gigRow); } catch (InvalidItemException) { throw new InvalidGigException(); } }
public static void Show(Core core, PPage page, long tourId) { page.Template.SetTemplate("Musician", "viewtour"); Tour tour = null; try { tour = new Tour(core, (Musician)page.Owner, tourId); } catch (InvalidTourException) { core.Functions.Generate404(); return; } core.Template.Parse("TOUR_TITLE", tour.Title); core.Template.Parse("TOUR_YEAR", tour.StartYear.ToString()); core.Template.Parse("U_TOUR", tour.Uri); core.Display.ParseBbcode("TOUR_ABSTRACT", tour.TourAbstract); List<Gig> gigs = tour.GetGigs(); foreach (Gig gig in gigs) { VariableCollection gigVariableCollection = core.Template.CreateChild("gig_list"); gigVariableCollection.Parse("ID", gig.Id.ToString()); gigVariableCollection.Parse("U_GIG", gig.Uri); gigVariableCollection.Parse("DESCRIPTION", gig.Abstract); gigVariableCollection.Parse("CITY", gig.City); gigVariableCollection.Parse("VENUE", gig.Venue); gigVariableCollection.Parse("DATE", core.Tz.DateTimeToDateString(gig.GetTime(core.Tz))); gigVariableCollection.Parse("COMMENTS", core.Functions.LargeIntegerToString(gig.Comments)); } List<string[]> tourPath = new List<string[]>(); tourPath.Add(new string[] { "tours", "Tours" }); tourPath.Add(new string[] { tour.Id.ToString(), tour.Title }); page.Owner.ParseBreadCrumbs(tourPath); }