예제 #1
0
        /// <summary>
        /// Validate that the event is related to a vaild show. 
        /// </summary>
        /// <param name="eventToValidate"></param>
        private void ValidateEvent(Event eventToValidate)
        {
            if (eventToValidate.ShowDetails == null)
            {
            }

            int id = eventToValidate.ShowDetails.ShowID;

            if (FindShowByID(id) == null)
            {
            }
        }
예제 #2
0
        public void UpdateEvent(Event newEvent)
        {
            ValidateEvent(newEvent);

            eventManager.UpdateEvent(newEvent);

            #region ClientNotifications
            //ClientNotifications
            string userName = string.Empty;
            if ((OperationContext.Current != null) && (OperationContext.Current.ServiceSecurityContext != null) && (OperationContext.Current.ServiceSecurityContext.PrimaryIdentity != null))
                userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;

            var clientRegistrations = MemoryRepository.Current.GetRegistrations(NotificationTypes.EventsNoification, userName);
            if (clientRegistrations.Length > 0)
                ClientNotificationsManager.SendNotifications(new EventMessage()
                {
                    Content = "Event Changed",
                    EventID = newEvent.EventID
                }, clientRegistrations);

            #endregion
        }
예제 #3
0
        private ListPriceRecord CreateListPriceRecord(Event ev)
        {
            IHallStateService prox = null;

            ListPriceRecord result = new ListPriceRecord()
            {
                ListPrice = (int)ev.ListPrice,
                EventDate = ev.Date,
                ShowName = ev.ShowDetails.Title

            };


            #region Get Theater Details
            lock (this)
            {
                if (chf == null)
                    chf = new ChannelFactory<IHallStateService>("HallStateEP");
            }

            try
            {
                prox = chf.CreateChannel();
                result.TheaterDetails = prox.FindTheater(string.Empty, ev.TheaterID);
            }
            catch (Exception ex)
            {
                LoggingManager.Logger.Log(LoggingCategory.Error, ex.Message);
                throw new FaultException<HallStateException>
                    (new HallStateException(string.Format(StringsResource.HallNotFound, ev.TheaterID), ex));
            }
            finally
            {
                var channel = prox as ICommunicationObject;
                if ((channel != null) && (channel.State == CommunicationState.Opened))
                    channel.Close();
            }
            #endregion

            return result;
        }
예제 #4
0
        public Guid CreateEvent(Event newEvent)
        {
            ValidateEvent(newEvent);

            #region Get Theater Details
            IHallStateService prox = null;
            lock (this)
            {
                if (chf == null)
                    chf = new ChannelFactory<IHallStateService>("HallStateEP");
            }

            try
            {
                prox = chf.CreateChannel();
                var theater = prox.FindTheater(string.Empty, newEvent.TheaterID);
                if (theater == null)
                    throw new NullReferenceException(string.Format(StringsResource.HallNotFound, newEvent.TheaterID));
            }
            catch (Exception ex)
            {
                LoggingManager.Logger.Log(LoggingCategory.Error, ex.Message);
                throw new HallStateException(string.Format(StringsResource.HallNotFound, newEvent.TheaterID), ex);
            }
            finally
            {
                var channel = prox as ICommunicationObject;
                if ((channel != null) && (channel.State == CommunicationState.Opened))
                    channel.Close();
            }
            #endregion

            var res = eventManager.CreateEvent(newEvent);

            #region ClientNotifications
            //ClientNotifications
            string userName = string.Empty;
            if ((OperationContext.Current != null) && (OperationContext.Current.ServiceSecurityContext != null) && (OperationContext.Current.ServiceSecurityContext.PrimaryIdentity != null))
                userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;


            var clientRegistrations = MemoryRepository.Current.GetRegistrations(NotificationTypes.EventsNoification, userName);
            if (clientRegistrations.Length > 0)
                ClientNotificationsManager.SendNotifications(new EventMessage()
                {
                    Content = "Event created",
                    EventID = newEvent.EventID
                }, clientRegistrations);

            #endregion

            return res;
        }