protected void createEvent(object sender, EventArgs e) { //edit? if (!string.IsNullOrEmpty(Request.QueryString["id"])) { Document d = new Document(int.Parse(Request.QueryString["id"])); //allowed? if (d.ContentType.Alias == "Event" && int.Parse(d.getProperty("owner").Value.ToString()) == m.Id) { d.Text = tb_name.Text; d.getProperty("description").Value = tb_desc.Text; d.getProperty("venue").Value = tb_venue.Text; d.getProperty("latitude").Value = tb_lat.Value; d.getProperty("longitude").Value = tb_lng.Value; bool sync = false; if (tb_capacity.Text != d.getProperty("capacity").Value.ToString()) { sync = true; } d.getProperty("capacity").Value = tb_capacity.Text; d.getProperty("start").Value = DateTime.Parse(dp_startdate.Text); d.getProperty("end").Value = DateTime.Parse(dp_enddate.Text); d.Save(); d.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); if (sync) { uEvents.Event ev = new uEvents.Event(d); ev.syncCapacity(); } Response.Redirect(umbraco.library.NiceUrl(d.Id)); } } else { Document d = Document.MakeNew(tb_name.Text, DocumentType.GetByAlias("Event"), new umbraco.BusinessLogic.User(0), EventsRoot); d.getProperty("description").Value = tb_desc.Text; d.getProperty("venue").Value = tb_venue.Text; d.getProperty("latitude").Value = tb_lat.Value; d.getProperty("longitude").Value = tb_lng.Value; d.getProperty("capacity").Value = tb_capacity.Text; d.getProperty("signedup").Value = 0; d.getProperty("start").Value = DateTime.Parse(dp_startdate.Text); d.getProperty("end").Value = DateTime.Parse(dp_enddate.Text); d.getProperty("owner").Value = m.Id; d.Save(); d.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); Response.Redirect(umbraco.library.NiceUrl(d.Id)); } }
protected void createEvent(object sender, EventArgs e) { var hasAnchors = false; var hasLowKarma = false; var documentId = 0; var karma = int.Parse(_member.getProperty("reputationTotal").Value.ToString()); if (karma < 50) { hasLowKarma = true; } //edit? if (string.IsNullOrEmpty(Request.QueryString["id"]) == false) { var document = new Document(int.Parse(Request.QueryString["id"])); documentId = document.Id; //allowed? if (document.ContentType.Alias == "Event" && int.Parse(document.getProperty("owner").Value.ToString()) == _member.Id) { SetDescription(document, hasLowKarma, ref hasAnchors); document.Text = tb_name.Text; document.getProperty("venue").Value = tb_venue.Text; document.getProperty("latitude").Value = tb_lat.Value; document.getProperty("longitude").Value = tb_lng.Value; var sync = tb_capacity.Text != document.getProperty("capacity").Value.ToString(); document.getProperty("capacity").Value = tb_capacity.Text; document.getProperty("start").Value = DateTime.Parse(dp_startdate.Text); document.getProperty("end").Value = DateTime.Parse(dp_enddate.Text); document.Save(); document.Publish(new User(0)); umbraco.library.UpdateDocumentCache(document.Id); if (sync) { var ev = new uEvents.Event(document); ev.syncCapacity(); } } } else { Document document = Document.MakeNew(tb_name.Text, DocumentType.GetByAlias("Event"), new User(0), EventsRoot); documentId = document.Id; SetDescription(document, hasLowKarma, ref hasAnchors); document.getProperty("venue").Value = tb_venue.Text; document.getProperty("latitude").Value = tb_lat.Value; document.getProperty("longitude").Value = tb_lng.Value; document.getProperty("capacity").Value = tb_capacity.Text; document.getProperty("signedup").Value = 0; document.getProperty("start").Value = DateTime.Parse(dp_startdate.Text); document.getProperty("end").Value = DateTime.Parse(dp_enddate.Text); document.getProperty("owner").Value = _member.Id; document.Save(); document.Publish(new User(0)); umbraco.library.UpdateDocumentCache(document.Id); } var redirectUrl = umbraco.library.NiceUrl(documentId); if (hasLowKarma && hasAnchors) SendPotentialSpamNotification(tb_name.Text, redirectUrl, _member.Id); Response.Redirect(redirectUrl); }