protected void btnSave_Click(object sender, EventArgs e)
        {
            bool bAdd = false;

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var currItem = (from c in db.carrot_CalendarEvents
                                where c.CalendarEventID == ItemGuid
                                select c).FirstOrDefault();

                if (currItem == null)
                {
                    bAdd     = true;
                    ItemGuid = Guid.NewGuid();
                    currItem = new carrot_CalendarEvent();
                    currItem.CalendarEventID = ItemGuid;
                }

                currItem.EventDetail = reContent.Text;
                currItem.IsCancelled = chkIsCancelled.Checked;

                currItem.EventStartTime = CalendarHelper.GetTimeSpanFromTextbox(txtEventStartTime);
                currItem.EventEndTime   = CalendarHelper.GetTimeSpanFromTextbox(txtEventEndTime);

                if (bAdd)
                {
                    db.carrot_CalendarEvents.InsertOnSubmit(currItem);
                }

                db.SubmitChanges();
            }

            Response.Redirect(CreateLink(ModuleName, String.Format("id={0}", ItemGuid)));
        }
        public static carrot_CalendarEventProfile CopyEvent(Guid calendarEventProfileID)
        {
            var srcProfile = GetProfile(calendarEventProfileID);

            using (CalendarDataContext db = CalendarDataContext.GetDataContext()) {
                var item = new carrot_CalendarEventProfile();
                item.CalendarEventProfileID = Guid.NewGuid();
                item.SiteID      = srcProfile.SiteID;
                item.EventDetail = srcProfile.EventDetail;

                item.EventRepeatPattern      = srcProfile.EventRepeatPattern;
                item.CalendarFrequencyID     = srcProfile.CalendarFrequencyID;
                item.CalendarEventCategoryID = srcProfile.CalendarEventCategoryID;

                item.EventStartDate = srcProfile.EventStartDate;
                item.EventEndDate   = srcProfile.EventEndDate;
                item.EventStartTime = srcProfile.EventStartTime;
                item.EventEndTime   = srcProfile.EventEndTime;

                item.IsPublic          = srcProfile.IsPublic;
                item.IsAllDayEvent     = srcProfile.IsAllDayEvent;
                item.IsCancelled       = srcProfile.IsCancelled;
                item.IsCancelledPublic = srcProfile.IsCancelledPublic;

                db.carrot_CalendarEventProfiles.InsertOnSubmit(item);

                if (srcProfile != null)
                {
                    var lst = (from m in db.carrot_CalendarEvents
                               where m.CalendarEventProfileID == calendarEventProfileID
                               select m);

                    foreach (carrot_CalendarEvent date in lst)
                    {
                        carrot_CalendarEvent evt = new carrot_CalendarEvent {
                            CalendarEventID        = Guid.NewGuid(),
                            CalendarEventProfileID = item.CalendarEventProfileID,
                            EventDate   = date.EventDate,
                            EventDetail = date.EventDetail,
                            IsCancelled = date.IsCancelled
                        };

                        db.carrot_CalendarEvents.InsertOnSubmit(evt);
                    }

                    db.SubmitChanges();
                }

                return(item);
            }
        }
Beispiel #3
0
        protected static void InsertEventsFromList(CalendarDataContext ctx, CalendarEvent item, List <DateTime> lstDates)
        {
            SiteData site = SiteData.CurrentSite;

            foreach (DateTime date in lstDates)
            {
                carrot_CalendarEvent evt = new carrot_CalendarEvent {
                    CalendarEventID        = Guid.NewGuid(),
                    CalendarEventProfileID = item.CalendarEventProfileID,
                    EventDate   = site.ConvertSiteTimeToUTC(date),
                    IsCancelled = false
                };

                ctx.carrot_CalendarEvents.InsertOnSubmit(evt);
            }
        }