Ejemplo n.º 1
0
		public static Event AddEvent(
			string name, 
			int venueK, 
			StartTimes? startTime, 
			DateTime date, 
			string shortDetails, 
			string safeLongDetails, 
			Guid? duplicateGuid, 
			int? capacity, 
			Usr usr, 
			int[] musicTypeKs, 
			int[] brandKs,
			bool spotterRequest,
			string spotterRequestName,
			string spotterRequestNumber)
		{
			Event ev = new Event();

			Venue venue = new Venue(venueK);
			Transaction t = null;//new Transaction();
			try
			{
				ev.AddedDateTime = DateTime.Now;
				ev.VenueK = venue.K;
				ev.Name = Cambro.Web.Helpers.StripHtml(name).Trim();
				ev.StartTime = startTime ?? StartTimes.Evening;;
				ev.DateTime = date;
				ev.ShortDetailsHtml = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(shortDetails ?? ""), 500);

				ev.LongDetailsHtml = safeLongDetails;

				ev.DuplicateGuid = duplicateGuid ?? Guid.NewGuid();

				ev.Capacity = capacity ?? venue.Capacity;

				ev.AdminNote += "Event added by owner " + DateTime.Now.ToString();

				ev.OwnerUsrK = Usr.Current.K;

				ev.SpotterRequest = spotterRequest;
				ev.SpotterRequestName = spotterRequestName;
				ev.SpotterRequestNumber = spotterRequestNumber;

				if (!usr.IsSuper)
				{
					ev.IsNew = true;
					ev.ModeratorUsrK = Usr.GetEventModeratorUsrK();
				}
				ev.InitUrlFragment();
				ev.Update(t);

				foreach (int musicTypeK in musicTypeKs ?? new int[]{})
				{
					MusicType mt = new MusicType(musicTypeK);
					EventMusicType emt = new EventMusicType();
					emt.EventK = ev.K;
					emt.MusicTypeK = mt.K;
					emt.Update(t);
				}
				foreach (int brandK in brandKs ?? new int[] { })
				{
					EventBrand eb = new EventBrand();
					eb.BrandK = brandK;
					eb.EventK = ev.K;
					eb.Update(t);
				}

				ev.UpdateMusicTypesString(t);

				ev.Venue.UpdateTotalEvents(t);
				ev.Owner.UpdateEventCount(t);

				//t.Commit();
				

			}
			catch (Exception ex)
			{
				//t.Rollback();
				ev.DeleteAll(null);
				throw ex;
			}
			finally
			{
				//t.Close();
			}

			Mailer sm = new Mailer();
			sm.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
			sm.UsrRecipient = Usr.Current;
			sm.To = Usr.Current.Email;
			sm.Subject = "You've added an event!";
			sm.Body += "<p>You've added an event to the DontStayIn events database.</p>";
			sm.Body += "<p>Click the link below to view the event:</p>";
			sm.Body += "<p><a href=\"[LOGIN(" + ev.Url() + ")]\">" + HttpUtility.HtmlEncode(ev.FriendlyName) + "</a></p>";
			sm.Body += "<h2>Make changes</h2>";
			sm.Body += "<p>You can make changes or corrections to the event details by clicking the link below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/event-" + ev.K.ToString() + "/edit)]\">Edit your event</a></p>";
			sm.Body += "<h2>How about a banner advert?</h2>";
			sm.Body += "<p>You can add a banner advert to your event by using the link below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/pages/bannerpreview/eventk-" + ev.K.ToString() + ")]\">Add a banner</a></p>";
			sm.Body += "<h2>Add photos or a review</h2>";
			sm.Body += "<p>After the event you can upload photos or add a review with the links below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/pages/galleries/add/eventk-" + ev.K.ToString() + ")]\">Add photos</a> or <a href=\"[LOGIN(" + ev.UrlApp("review") + ")]\">add a review</a></p>";
			sm.Body += "<h2>Are you the event promoter?</h2>";
			sm.Body += "<p>If you organise this event, you can sign up for a FREE promoter account by using the link below:</p>";
			sm.Body += "<p><a href=\"[LOGIN(/pages/promoters/edit)]\">Apply for a promoter account</a></p>";
			sm.RedirectUrl = ev.Url();
			sm.Send();
			return ev;

		}
Ejemplo n.º 2
0
		public int DuplicateEvent()
		{
			Transaction t = null;//new Transaction();
			Event ev = new Event();
			try
			{
				ev.AddedDateTime = DateTime.Now;
				ev.VenueK = SelectedEvent.VenueK;
				ev.Name = SelectedEvent.Name;
				ev.StartTime = SelectedEvent.StartTime;
				ev.DateTime = NewDateCalendar.SelectedDate;
				ev.ShortDetailsHtml = SelectedEvent.ShortDetailsHtml;
				ev.LongDetailsHtml = SelectedEvent.LongDetailsHtml;
				ev.IsDescriptionText = SelectedEvent.IsDescriptionText;
				ev.IsDescriptionCleanHtml = SelectedEvent.IsDescriptionCleanHtml;
				ev.Capacity = SelectedEvent.Capacity;
				ev.AdminNote = "Event copied from event " + SelectedEvent.K.ToString() + " by owner " + DateTime.Now.ToString();

				if (SelectedEvent.AdminNote.Length > 0)
					ev.AdminNote += "\nprevious admin note: \n*******\n" + SelectedEvent.AdminNote + "\n*******";

				ev.OwnerUsrK = Usr.Current.K;

				ev.IsNew = true;
				ev.ModeratorUsrK = Usr.GetEventModeratorUsrK();
				
				ev.InitUrlFragment();
				ev.Update(t);
				if (SelectedEvent.Pic != Guid.Empty)
				{
					ev.Pic = Guid.NewGuid();

					Storage.AddToStore(
						Storage.GetFromStore(Storage.Stores.Pix, SelectedEvent.Pic, "jpg"),
						Storage.Stores.Pix,
						ev.Pic,
						"jpg",
						ev,
						"Pic");

				}
				ev.Update(t);
				

				foreach (Brand b in SelectedEvent.Brands)
				{
					EventBrand eb = new EventBrand();
					eb.BrandK = b.K;
					eb.EventK = ev.K;
					eb.Update(t);
				}

				ev.Venue.UpdateTotalEvents(t);
				ev.Owner.UpdateEventCount(t);

				if (SelectedEvent.MusicTypes.Count > 0)
				{
					foreach (MusicType mt in SelectedEvent.MusicTypes)
					{
						EventMusicType emt = new EventMusicType();
						emt.EventK = ev.K;
						emt.MusicTypeK = mt.K;
						emt.Update(t);
					}
				}
				ev.UpdateMusicTypesString(t);

				//t.Commit();
			}
			catch (Exception ex)
			{
				//t.Rollback();
				ev.DeleteAll(null);
				if (!ev.Pic.Equals(Guid.Empty))
				{
					Storage.RemoveFromStore(Storage.Stores.Pix, ev.Pic, "jpg");
				}
				throw ex;
			}
			finally
			{
				//t.Close();
			}

			return ev.K;

		}