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); }
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); }
public void Unsubscribe(IEventServicesCallback currentCallbackProxy) { if (_subscribers.Contains(currentCallbackProxy)) { _subscribers.Remove(currentCallbackProxy); } }
public void Subscribe(IEventServicesCallback currentCallbackProxy) { if (!_subscribers.Contains(currentCallbackProxy)) { _subscribers.Add(currentCallbackProxy); } }
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); } } }
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); }
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); }
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); }
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); }
public void Unsubscribe() { IEventServicesCallback currentCallbackProxy = OperationContext.Current.GetCallbackChannel <IEventServicesCallback>(); EventServiceCallback.Instance.Unsubscribe(currentCallbackProxy); }