protected void btnUploadFile_Click(object sender, EventArgs e) { //check if a file is selected if (uploadAttachment.HasFile) { uploadAttachment.SaveAs(Server.MapPath("/UploadedXml/") + uploadAttachment.FileName.Split('.')[0] + Path.GetExtension(uploadAttachment.FileName)); XElement document = XElement.Load(Server.MapPath("/UploadedXml/") + uploadAttachment.FileName); ContentTypeManager<Holiday> contentTypeManagerHoliday = new ContentTypeManager<Holiday>(); foreach (var booking in document.Elements()) { Holiday holiday = new Holiday(); holiday.FirstName = booking.Element("customer").Element("firstname").Value; holiday.LastName = booking.Element("customer").Element("lastname").Value; holiday.Email = booking.Element("customer").Element("email").Value; holiday.Phone = booking.Element("customer").Element("phone").Value; holiday.HolidayType = booking.Element("holiday").Element("type").Value; holiday.HolidayCountry = booking.Element("holiday").Element("destination").Value; holiday.HolidayDate = booking.Element("holiday").Element("date").Value; holiday.Comments = booking.Element("holiday").Element("comments").Value; ContentType<Holiday> holidayContent = new ContentType<Holiday>(); holidayContent.Content = new Ektron.Cms.ContentData(); holidayContent.Content.FolderId = 102; holidayContent.Content.Title = booking.Attribute("name").Value; holidayContent.SmartForm = holiday; contentTypeManagerHoliday.Add(holidayContent); } litMessage.Text = "Successfully added " + document.Elements().ToArray().Length + " items to the CMS"; } }
public void btnBookHoliday_Click(object sender, EventArgs e) { Page.Validate(); Holiday holiday = new Holiday(); holiday.FirstName = txtFirstName.Text; holiday.LastName = txtLastName.Text; holiday.Email = txtEmail.Text; holiday.Phone = txtPhone.Text; holiday.HolidayType = RadioHolidayType.SelectedValue; holiday.HolidayCountry = ddlCountries.SelectedValue; holiday.HolidayDate = clndrHolidayDate.SelectedDate.ToString(); holiday.Comments = tbComments.Text; ContentTypeManager<Holiday> contentTypeManager = new ContentTypeManager<Holiday>(); ContentType<Holiday> newHoliday = new ContentType<Holiday>(); newHoliday.Content = new ContentData(); newHoliday.Content.FolderId = 102; newHoliday.Content.Title = holiday.FirstName + "-" + holiday.HolidayCountry + "-" + holiday.HolidayDate; newHoliday.SmartForm = holiday; // adds content to the CMS contentTypeManager.Add(newHoliday); Response.Redirect("/Source/Wireframes/Pagination.aspx"); }