Exemplo n.º 1
0
        public Event RescheduleEvent(Int32 eventId, DateTime newBegining, DateTime newEnd)
        {
            Event foundEvent = DbManager.Instance.GetSingleEvent(eventId);

            if (foundEvent == null)
            {
                return(null);
            }

            foundEvent.ScheduledDateTimeBeging = newBegining;
            foundEvent.ScheduledDateTimeEnd    = newEnd;
            foundEvent.LastEditTimeStamp       = DateTime.Now;

            Event rescheduledEvent = DbManager.Instance.ModifyEvent(foundEvent);

            if (rescheduledEvent != null)
            {
                IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();
                EventServiceCallback.Instance.NotifyAllEventModification(rescheduledEvent, currentCallbackProxy);

                rescheduledEvent.Participants = new List <Person>();
                return(rescheduledEvent);
            }

            return(null);
        }
Exemplo n.º 2
0
        public Event RemoveParticipants(Int32 eventId, List <Person> participants)
        {
            Event foundEvent = DbManager.Instance.GetSingleEvent(eventId);

            if (foundEvent == null)
            {
                return(null);
            }

            List <Person> participantsToRemove = participants.Where(p => foundEvent.Participants.Contains(p, new PersonComparer())).ToList();

            participantsToRemove.ForEach(p => foundEvent.RemoveParticipant(p));

            Event modifiedEvent = DbManager.Instance.ModifyEvent(foundEvent);

            if (modifiedEvent != null)
            {
                IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();
                EventServiceCallback.Instance.NotifyAllEventModification(modifiedEvent, currentCallbackProxy);

                modifiedEvent.Participants = new List <Person>();
                return(modifiedEvent);
            }

            return(null);
        }
Exemplo n.º 3
0
 public void Unsubscribe(IEventServicesCallback currentCallbackProxy)
 {
     if (_subscribers.Contains(currentCallbackProxy))
     {
         _subscribers.Remove(currentCallbackProxy);
     }
 }
Exemplo n.º 4
0
 public void Subscribe(IEventServicesCallback currentCallbackProxy)
 {
     if (!_subscribers.Contains(currentCallbackProxy))
     {
         _subscribers.Add(currentCallbackProxy);
     }
 }
Exemplo n.º 5
0
        public void NotifyAllEventModification(Event modifiedEvent, IEventServicesCallback currentCallbackProxy)
        {
            modifiedEvent.Participants.ForEach(p => p.ScheduledEvents.ForEach(e => e.Participants.ForEach(pa => pa.ScheduledEvents = new List <Event>())));

            if (_subscribers.Count > 0)
            {
                foreach (IEventServicesCallback sub in _subscribers)
                {
                    sub.NotifyEventModification(modifiedEvent);
                }
            }
        }
Exemplo n.º 6
0
        public Event EditEvent(Event eventToEdit)
        {
            Event editedEvent = DbManager.Instance.ModifyEvent(eventToEdit);

            if (editedEvent != null)
            {
                IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();
                EventServiceCallback.Instance.NotifyAllEventModification(editedEvent, currentCallbackProxy);

                editedEvent.Participants = new List <Person>();
                return(editedEvent);
            }

            return(null);
        }
Exemplo n.º 7
0
        public Event CancleEvent(Event eventToCancle)
        {
            Event cancledEvent = DbManager.Instance.DeleteEvent(eventToCancle);

            if (cancledEvent != null)
            {
                IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();
                EventServiceCallback.Instance.NotifyAllEventRemoval(cancledEvent, currentCallbackProxy);

                cancledEvent.Participants = new List <Person>();
                return(cancledEvent);
            }

            return(null);
        }
Exemplo n.º 8
0
        public Event ScheduleEvent(Event eventToSchedule, List <Person> participants)
        {
            List <Person> participantsToAdd = participants.Where(p => !eventToSchedule.Participants.Contains(p, new PersonComparer())).ToList();

            participantsToAdd.ForEach(p => eventToSchedule.AddParticipant(p));

            Event scheduledEvent = DbManager.Instance.AddEvent(eventToSchedule);

            if (scheduledEvent != null)
            {
                IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();
                EventServiceCallback.Instance.NotifyAllEventAddition(scheduledEvent, currentCallbackProxy);

                scheduledEvent.Participants = new List <Person>();
                return(scheduledEvent);
            }

            return(null);
        }
Exemplo n.º 9
0
        public Event EditEventDescription(Int32 eventId, string newDescription)
        {
            Event foundEvent = DbManager.Instance.GetSingleEvent(eventId);

            if (foundEvent == null)
            {
                return(null);
            }

            foundEvent.Description = newDescription;

            Event modifiedEvent = DbManager.Instance.ModifyEvent(foundEvent);

            if (modifiedEvent != null)
            {
                IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();
                EventServiceCallback.Instance.NotifyAllEventModification(modifiedEvent, currentCallbackProxy);

                modifiedEvent.Participants = new List <Person>();
                return(modifiedEvent);
            }

            return(null);
        }
Exemplo n.º 10
0
        public void Unsubscribe()
        {
            IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>();

            EventServiceCallback.Instance.Unsubscribe(currentCallbackProxy);
        }