Example #1
0
 public string Sync(int eventId)
 {
     var umbracoEvent = new Event(eventId);
     umbracoEvent.syncCapacity();
     return "true";
 }
Example #2
0
        protected void createEvent(object sender, EventArgs e)
        {
            var hasAnchors = false;
            var hasLowKarma = false;

            var karma = int.Parse(_member.getProperty("reputationTotal").Value.ToString());
            if (karma < 50)
            {
                hasLowKarma = true;
            }

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var contentService = ApplicationContext.Current.Services.ContentService;

            IContent content;

            //edit?
            if (string.IsNullOrEmpty(Request.QueryString["id"]) == false)
            {
                content = contentService.GetById(int.Parse(Request.QueryString["id"]));
                var publishedContent = umbracoHelper.TypedContent(Request.QueryString["id"]);

                //allowed?
                if (publishedContent.DocumentTypeAlias == "Event" && publishedContent.GetPropertyValue<int>("owner") == _member.Id)
                {
                    content = SetDescription(content, hasLowKarma, ref hasAnchors);

                    content.Name = tb_name.Text;

                    content.SetValue("venue", tb_venue.Text);
                    content.SetValue("latitude", tb_lat.Value);
                    content.SetValue("longitude", tb_lng.Value);

                    content.SetValue("capacity", tb_capacity.Text);

                    var startDate = GetProperDate(dp_startdate.Text);
                    var endDate = GetProperDate(dp_enddate.Text);

                    content.SetValue("start", startDate);
                    content.SetValue("end", endDate);

                    var sync = tb_capacity.Text != publishedContent.GetPropertyValue<string>("capacity");

                    contentService.SaveAndPublishWithStatus(content);

                    if (sync)
                    {
                        var ev = new Event(publishedContent);
                        ev.syncCapacity();
                    }
                }
            }
            else
            {
                content = contentService.CreateContent(tb_name.Text, EventsRoot, "Event");

                content = SetDescription(content, hasLowKarma, ref hasAnchors);

                content.SetValue("venue", tb_venue.Text);
                content.SetValue("latitude", tb_lat.Value);
                content.SetValue("longitude", tb_lng.Value);

                content.SetValue("capacity", tb_capacity.Text);

                var startDate = GetProperDate(dp_startdate.Text);
                var endDate = GetProperDate(dp_enddate.Text);

                content.SetValue("start", startDate);
                content.SetValue("end", endDate);

                content.SetValue("owner", _member.Id);

                content.SetValue("signedup", 0);
                contentService.SaveAndPublishWithStatus(content);
            }

            var redirectUrl = umbraco.library.NiceUrl(content.Id);

            if (hasLowKarma && hasAnchors)
                SendPotentialSpamNotification(tb_name.Text, redirectUrl, _member.Id);

            Response.Redirect(redirectUrl);
        }