public ActionResult New(ArborEventModel model) { var arbor = Services.ContentService.GetById(model.ArborId); var eventsFolder = arbor.Children().FirstOrDefault(x => x.ContentType.Alias == CONTENT_ALIAS_EVENTS); if (eventsFolder == null) // create Events folder { eventsFolder = Services.ContentService.CreateContent("Events", model.ArborId, CONTENT_ALIAS_EVENTS); Services.ContentService.PublishWithStatus(eventsFolder); } var content = Services.ContentService.CreateContent(model.Title, eventsFolder.Id, CONTENT_ALIAS_EVENT); SetModelToContent(ref content, model); Services.ContentService.PublishWithStatus(content); UpdateAttendeeList(content, model.AttendeesJson); return RedirectToCurrentUmbracoPage(); }
private static void SetModelToContent(ref IContent content, ArborEventModel model) { DateTime startDate; DateTime.TryParse(model.StartDate + " " + model.StartTime, out startDate); DateTime endDate; DateTime.TryParse(model.EndDate + " " + model.EndTime, out endDate); content.SetValue("title", model.Title); content.SetValue("description", model.Description); content.SetValue("startDate", startDate); content.SetValue("endDate", endDate); content.SetValue("location", JsonConvert.SerializeObject(new List<Address> { new Address() { Street = model.Street, City = model.City, State = model.State, ZipCode = model.ZipCode } })); content.SetValue("links", JsonConvert.SerializeObject(new List<SocialLinks> { new SocialLinks() { Facebook = model.Facebook, Twitter = model.Twitter, Instagram = model.Instagram, Blog = model.Blog } })); content.SetValue("images", model.Images); }
public ActionResult Edit(ArborEventModel model) { var content = Services.ContentService.GetById(model.Id); SetModelToContent(ref content, model); Services.ContentService.PublishWithStatus(content); UpdateAttendeeList(content, model.AttendeesJson); return RedirectToCurrentUmbracoPage(); }