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>(); CloseSession(); return (rowcount == 0); }
public void SubscribeSignal(SignalSubscription ss) { OpenSession(); session.Save(ss); CloseSession(); }
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"); }