Пример #1
0
        public IEnumerable <IUser> InviteesByStatus(Guid userId, Guid eventId, EventAttendantsStatus attendStatus)
        {
            try
            {
                if (userId == new Guid("99999999-9999-9999-9999-999999999999") || userId == new Guid())
                {
                    throw new InvalidEventIdException(string.Format("Invalid UserId passed to the InviteesByStatus method: {0} ", userId.ToString()));
                }

                if (eventId == new Guid("99999999-9999-9999-9999-999999999999") || eventId == new Guid())
                {
                    throw new InvalidEventIdException(string.Format("Invalid eventId passed to the InviteesByStatus method: {0} ", eventId.ToString()));
                }

                IEvent evt = FindEvent(eventId);

                if (!EvtRepository.Guest(evt, userId) && (userId != EvtRepository.Owner(evt)))
                {
                    throw new EventException("User is not the owner of the event, nor an invited guest.");
                }

                var results = EvtRepository.AttendingByStatus(eventId, attendStatus);
                return(results);
            }
            catch (Exception ex)
            {
                Logger.Instance.Log = new ExceptionDTO()
                {
                    FaultClass = "EventFacade", FaultMethod = "EventAttendeesByStatus", Exception = ex
                };
                throw;
            }
        }
Пример #2
0
        public void UpdateEvent(Guid userId, IEvent evt)
        {
            try
            {
                if (!ValidateEventRequiredFields(evt, false))
                {
                    throw new InvalidIEventObjectException();
                }

                if (userId != EvtRepository.Owner(evt))
                {
                    throw new UserNotOwnerException();
                }

                EvtRepository.Update(evt);

                //Add code here for Messaging (RTF)
            }
            catch (Exception ex)
            {
                Logger.Instance.Log = new ExceptionDTO()
                {
                    FaultClass = "EventFacade", FaultMethod = "UpdateEvent", Exception = ex
                };
                throw;
            }
        }
Пример #3
0
        public void AddContactsToEvent(Guid userId, Guid eventId, List <Guid> contactList)
        {
            try
            {
                IEvent evt = FindEvent(eventId);

                var ownerId = EvtRepository.Owner(evt);
                if (userId != ownerId)
                {
                    throw new EventException("Only the owner can add guest to the event.");
                }

                using (UserFacade userFacade = new UserFacade(_realTimeBroker))
                {
                    var owner = userFacade.FindUser(ownerId);

                    /*if (owner.UserChannel == null)
                     * {
                     *  owner.UserChannel = _realTimeBroker.ConvertUserToTableName(owner);
                     * }*/

                    foreach (var contactId in contactList)
                    {
                        if (EvtRepository.Guest(evt, contactId))
                        {
                            continue;
                        }

                        IUser contact = userFacade.FindUser(contactId);
                        if (contact != null)
                        {
                            /*if (contact.UserChannel == null)
                             * {
                             *  contact.UserChannel = _realTimeBroker.ConvertUserToTableName(contact);
                             * } */
                            EvtRepository.LinkToEvent(contact, evt);

                            //Here Add code for Real Time Framework
                            var eventList    = userFacade.RetrieveEventsByAttendanceStatus(contactId, EventAttendantsStatus.All);
                            var channelsList = new List <string>()
                            {
                                contact.UserChannel
                            };
                            channelsList.AddRange(eventList.Select(e => RTBroker.ConvertEventToTableName(e)));
                            RTBroker.AuthUser(channelsList, contact.Token);
                            RTBroker.SendInvite(contact, evt.ID.ToString(), owner.Name);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Log = new ExceptionDTO()
                {
                    FaultClass = "EventFacade", FaultMethod = "AddContactsToEvent", Exception = ex
                };
                throw;
            }
        }
Пример #4
0
        public IEvent EventDetail(Guid userId, Guid eventId)
        {
            IEvent evt = FindEvent(eventId);

            if (!EvtRepository.Guest(evt, userId) && (userId != EvtRepository.Owner(evt)))
            {
                throw new EventException("User is not the owner of the event, nor an invited guest.");
            }
            else
            {
                return(evt);
            }
        }