public void insertevent(calendar_globalevent newe, Guid target )
        {
            string sourceuser= (Membership.GetUser(newe.userid,true)).UserName;
            string targuser="";
            calendar_notification newnot = null;
            if(target!=null)
               targuser = (Membership.GetUser(target,true)).UserName;

            if (newe.eventtype == "addfriend")
            {
                //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 + " added " + targuser + " as a friend !";
                DAL.GlobalEvent_DAL.insertevent(db, newe);
                if (!sourceuser.Equals(targuser))
                {
                    //add notification says someone added him as friend
                    newnot = new calendar_notification();
                    newnot.eventtype = "addfriend";
                    newnot.content = sourceuser + " added you as friend";
                    newnot.userid = target;
                    newnot.userid2 = newe.userid;
                    DAL.Notification_DAL.insert(db, newnot);

                }
            }

            else if (newe.eventtype == "commentedOnWall")
            {
                //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 + " Commented on " + targuser + "'s wall !";
                DAL.GlobalEvent_DAL.insertevent(db, newe);
                if (!sourceuser.Equals(targuser))
                {
                    //add notification says someone commented on his wall
                    newnot = new calendar_notification();
                    newnot.content = sourceuser + " commented on your wall";
                    newnot.userid = target;
                    newnot.userid2 = newe.userid;
                    newnot.eventtype = "commentedOnWall";
                    DAL.Notification_DAL.insert(db, newnot);
                }
            }
            else 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: " + targuser + "'s wall !";
                DAL.GlobalEvent_DAL.insertevent(db, newe);
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the calendar_notification EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocalendar_notification(calendar_notification calendar_notification)
 {
     base.AddObject("calendar_notification", calendar_notification);
 }
 /// <summary>
 /// Create a new calendar_notification object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="eventtype">Initial value of the eventtype property.</param>
 /// <param name="userid">Initial value of the userid property.</param>
 /// <param name="createtime">Initial value of the createtime property.</param>
 /// <param name="content">Initial value of the content property.</param>
 public static calendar_notification Createcalendar_notification(global::System.Guid id, global::System.String eventtype, global::System.Guid userid, global::System.DateTime createtime, global::System.String content)
 {
     calendar_notification calendar_notification = new calendar_notification();
     calendar_notification.id = id;
     calendar_notification.eventtype = eventtype;
     calendar_notification.userid = userid;
     calendar_notification.createtime = createtime;
     calendar_notification.content = content;
     return calendar_notification;
 }
        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);
        }