Exemple #1
0
 /// <summary>
 /// use to write cancel subscription objects to mongo DB
 /// </summary>
 /// <returns>true if successful</returns>
 public bool WriteunsubscribeData(CancelledSubscription info)
 {
     try
     {
         //Write object to Mongo DB Collection
         var mongoDatabase = MongoConnection.Connect();
         mongoDatabase.GetCollection<CancelledSubscription>(CancelledSubscriptionCollection).Insert(info);
         return true;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return false;
     }
 }
Exemple #2
0
 /// <summary>
 /// Unsubscribes User
 /// </summary>
 /// <param name="_username">User name</param>
 /// <param name="_message">comments</param>
 /// <returns>true if success</returns>
 public bool CancelSubscription(string _username, string _message)
 {
     try
     {
         //Update Status in SQL Server
         using (var cn = new SqlConnection(@"Data Source=(LocalDB)"))
         {
             string _sql = @"UPDATE [dbo].[System_Users] SET Active = 0 WHERE [Username] = @e";
             var cmd = new SqlCommand(_sql, cn);
             cmd.Parameters
                 .Add(new SqlParameter("@e", SqlDbType.NVarChar))
                 .Value = _username;
             cn.Open();
             cmd.ExecuteNonQuery();
         }
         CancelledSubscription info = new CancelledSubscription();
         info.Date = DateTimeOffset.Now;
         info.Username = _username;
         info.Message = _message;
         Mongo MongoWrite = new Mongo();
         MongoWrite.WriteunsubscribeData(info);
         return true;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return false;
     }
 }