/// <summary>
 /// Create a new calendar_event object.
 /// </summary>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="eventid">Initial value of the eventid property.</param>
 /// <param name="content">Initial value of the content property.</param>
 /// <param name="createtime">Initial value of the createtime property.</param>
 public static calendar_event Createcalendar_event(global::System.Guid userId, global::System.Guid eventid, global::System.String content, global::System.DateTime createtime)
 {
     calendar_event calendar_event = new calendar_event();
     calendar_event.UserId = userId;
     calendar_event.eventid = eventid;
     calendar_event.content = content;
     calendar_event.createtime = createtime;
     return calendar_event;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the calendar_event EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocalendar_event(calendar_event calendar_event)
 {
     base.AddObject("calendar_event", calendar_event);
 }
        public void insertevent(calendar_globalevent newe, Page page,calendar_event evt )
        {
            /*handels new calendar event case, eventtittle is the event tittle*/
            string sourceuser = (Membership.GetUser(newe.userid, true)).UserName;
            string targuser  = (Membership.GetUser(evt.UserId, true)).UserName;
            calendar_notification newnot = null;
            if (newe.eventtype == "addedcalevent")
            {
                //here we dont need to init redirecturl, because we only need it when the event is "new calendar event added", which redirecturl is the link to the new event
                newe.content = sourceuser + " Created Calendar Event: " + evt.tittle;
            }
            else if (newe.eventtype == "joinevent")
            {
                newe.content = sourceuser + " joined " + targuser+" 's Event: "+evt.tittle;

                if (!sourceuser.Equals(targuser))
                {
                    newnot = new calendar_notification();
                    newnot.content = sourceuser + " Joined your event: "+evt.tittle;
                    newnot.userid = evt.UserId;
                    newnot.userid2 = newe.userid;
                    newnot.eventtype = "joinevent";
                    newnot.redirecturl = "eventroom.aspx?eventid=" + evt.eventid + "&tittle=" + evt.tittle + "&event=" +
                                        page.Server.UrlEncode(evt.content) + "&username="******"&date=" + evt.createtime + "&place=" + evt.place;
                    DAL.Notification_DAL.insert(db, newnot);
                }
            }
                newe.redirecturl = "eventroom.aspx?eventid=" + evt.eventid + "&tittle=" + evt.tittle + "&event=" +
                                    page. Server.UrlEncode(evt.content) + "&username="******"&date=" + evt.createtime + "&place=" + evt.place;

                DAL.GlobalEvent_DAL.insertevent(db, newe);
        }