Example #1
0
        /// <summary>
        /// Checks if email is subscribed to the signal
        /// </summary>
        /// <param name="ss">The signal subscription information</param>
        /// <returns>True if already subscribed otherwise false</returns>
        public bool CheckIfSubscribed(SignalSubscription ss)
        {
            OpenSession();

            int rowcount = Session.CreateCriteria(typeof(SignalSubscription))
                .Add(Restrictions.Eq("SignalID", ss.SignalID))
                .Add(Restrictions.Eq("Email", ss.Email))
                .SetProjection(Projections.RowCount()).UniqueResult<int>();

            return !(rowcount == 0);
        }
Example #2
0
 /// <summary>
 /// Subscribes email to the signal.
 /// </summary>
 /// <param name="ss">The ss.</param>
 public void SubscribeSignal(SignalSubscription ss)
 {
     OpenSession();
     Session.Save(ss);
 }
Example #3
0
        public void SubscribeSignal(JsonObject param)
        {
            CheckRequest(param["ajaxSessionKey"].ToString());

            SignalManager sm = new SignalManager();
            SignalSubscription ss = new SignalSubscription();
            ss.Email = param["email"].ToString();
            ss.SignalID = Convert.ToInt32(param["signalID"]);

            if (!sm.CheckIfSubscribed(ss))
                sm.SubscribeSignal(ss);
            else
                throw new Exception("Sei giĆ  iscritto a questa segnalazione");
        }