Esempio n. 1
0
 public ActionResult FAQ()
 {
     User user = new User();
     Mongo mongo = new Mongo();
     user.FAQs = mongo.GetFAQ();
     return View(user);
 }
Esempio n. 2
0
 /// <summary>
 /// Gets all active support tickets associated with a user
 /// </summary>
 /// <returns>true if success</returns>
 public List<SupportTicket> GetSupportTickets(string _username)
 {
     try
     {
         //Read Tickets from MongoDB
         Mongo MongoRead = new Mongo();
         return MongoRead.GetTickets(_username);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return null;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Get lifetime messages sent
 /// </summary>
 public string GetLifetimeMessageCount(string username)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         return Convert.ToString(MongoWrite.GetTotalSent(username));
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return String.Empty;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Gets saved contacts
 /// </summary>
 public List<Contact> GetContacts(string username)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         return MongoWrite.GetContacts(username);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return null;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Deletes existing contact
 /// </summary>
 public void DeleteContact(string username, int position)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.DeleteExistingContact(username, position);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 6
0
 public ActionResult SaveBillingCardInfo(UserModel.User user, System.Web.Mvc.FormCollection collection)
 {
     var billingID = user.GetBillingID(User.Identity.Name);
     if (billingID != String.Empty)
     {
         Customer customer = Gateway.BrainTreeGateway.Customer.Find(billingID);
         string token = customer.CreditCards[0].Token;
         var request = new CustomerRequest
         {
             CreditCard = new CreditCardRequest
             {
                 CardholderName = collection["name"],
                 Number = collection["number"],
                 ExpirationMonth = collection["month"],
                 ExpirationYear = collection["year"],
                 CVV = collection["cvv"],
                 Options = new CreditCardOptionsRequest
                 {
                     UpdateExistingToken = token
                 }
             }
         };
         Result<Customer> updateResult = Gateway.BrainTreeGateway.Customer.Update(billingID, request);
         if (updateResult.IsSuccess())
         {
             var mongo = new Mongo();
             var config = mongo.GetUserConfiguration(User.Identity.Name);
             if (config.AccountInfoNotification)
             {
                 MailgunAgent.SendChangeEmail(user.GetCurrentEmail(User.Identity.Name), "Your Queue View credit card has been changed.");
             }
             return RedirectToAction("AccountDashboard", "User", new { ADCC = "ChangeCard" });
         }
         else
         {
             //Fail to update with Braintree
             return RedirectToAction("AccountDashboard", "User", new { ADCCFAIL = updateResult.Message });
         }
     }
     else
     {
         //Fail to retrieve Billing ID
         return RedirectToAction("Error", "User");
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Sends Text Message
 /// </summary>
 public void SavePosition(string username, string positions)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.UpdatePosition(username, positions);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Saves new contact
 /// </summary>
 public void SaveNewContact(Contact contact)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.WriteNewContact(contact);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 9
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;
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Validates hash, updates DB
 /// </summary>
 /// <param name="_hash">User name</param>
 /// <returns>HashValidation</returns>
 public HashValidation ValidateHash(string _hash, string _password)
 {
     try
     {
         //Get UserID corresponding to hash
         var ExpiredHash = false;
         var RetrievedToken = new PasswordResetInfo();
         RetrievedToken.Redeemed = true;
         RetrievedToken.RedemptionTime = DateTimeOffset.Now;
         Mongo MongoRead = new Mongo();
         var MongoResults = new List<PasswordResetInfo>();
         MongoResults = MongoRead.GetPasswordResetData();
         foreach (var result in MongoResults)
         {
             if (result.ResetHash.ToString() == _hash && result.Expiration > DateTime.Now)
             {
                 RetrievedToken.CustomerId = result.CustomerId;
                 RetrievedToken._id = new ObjectId();
                 RetrievedToken._id = result._id;
                 RetrievedToken.Expiration = result.Expiration;
                 RetrievedToken.ResetHash = result.ResetHash;
                 if (result.Redeemed)
                 {
                     //Hash expired
                     return HashValidation.Expired;
                 }
                 break;
             }
             if (result.ResetHash.ToString() == _hash && result.Expiration < DateTime.Now)
             {
                 //Hash expired
                 ExpiredHash = true;
             }
         }
         if (RetrievedToken.CustomerId == String.Empty || RetrievedToken.CustomerId == null)
         {
             if (ExpiredHash)
             {
                 //Hash expired
                 return HashValidation.Expired;
             }
             //Hash not found
             return HashValidation.NotFound;
         }
         //Update Password in SQL Server
         using (var cn = new SqlConnection(@"Data Source=(LocalDB)"))
         {
             string _sql = @"UPDATE [dbo].[System_Users] SET Password=@e WHERE [Id] = @c";
             var cmd = new SqlCommand(_sql, cn);
             cmd.Parameters
                 .Add(new SqlParameter("@e", SqlDbType.NVarChar))
                 .Value = BusinessLogic.SHA1.Encode(_password);
             cmd.Parameters
                 .Add(new SqlParameter("@c", SqlDbType.NVarChar))
                 .Value = RetrievedToken.CustomerId;
             cn.Open();
             cmd.ExecuteNonQuery();
         }
         // Set Redeemed and Redemption Time for applicable MongoDb Collection
         Mongo MongoWrite = new Mongo();
         MongoWrite.UpdatePasswordResetData(RetrievedToken);
         return HashValidation.Validated;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return HashValidation.NotFound;
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Updates username
 /// </summary>
 /// <param name="_username">User name</param>
 /// <returns>true if success</returns>
 public bool UpdateUsername(string _username, string _existingUsername)
 {
     try
     {
         //Update Username in SQL Server
         using (var cn = new SqlConnection(@"Data Source=(LocalDB)"))
         {
             string _sql = @"UPDATE [dbo].[System_Users] SET Username = @e WHERE [Username] = @c";
             var cmd = new SqlCommand(_sql, cn);
             cmd.Parameters
                 .Add(new SqlParameter("@e", SqlDbType.NVarChar))
                 .Value = _username;
             cmd.Parameters
                 .Add(new SqlParameter("@c", SqlDbType.NVarChar))
                 .Value = _existingUsername;
             cn.Open();
             cmd.ExecuteNonQuery();
         }
         var mongo = new Mongo();
         var config = mongo.GetUserConfiguration(_existingUsername);
         if (config.AccountInfoNotification)
         {
             MailgunAgent.SendChangeEmail(GetCurrentEmail(_username), "Your Queue View username has been updated.");
         }
         mongo.UpdateUsernameInAllCollections(_username, _existingUsername);
         return true;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return false;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Updates send status
 /// </summary>
 public void UpdateSend(string username, int position)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.UpdateSend(username, position);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Updates user info to SQL Server
 /// </summary>
 /// <returns>EmailUpdateStatus</returns>
 public EmailUpdateStatus UpdateEmail(string _email, string _username)
 {
     try
     {
         var UpdateEmail = false;
         using (var cn = new SqlConnection(@"Data Source=(LocalDB)"))
         {
             string _sql = @"SELECT [Email] FROM [dbo].[System_Users] " + @"WHERE [Username] = @e";
             var cmd = new SqlCommand(_sql, cn);
             cmd.Parameters
                 .Add(new SqlParameter("@e", SqlDbType.NVarChar))
                 .Value = _username;
             cn.Open();
             var reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 if (_email != reader[0].ToString())
                 {
                     UpdateEmail = true;
                     break;
                 }
             }
         }
         if (UpdateEmail)
         {
             using (var cn = new SqlConnection(@"Data Source=(LocalDB)"))
             {
                 string _sql2 = @"UPDATE [dbo].[System_Users] SET Email = @e WHERE [Username] = @c";
                 var cmd2 = new SqlCommand(_sql2, cn);
                 cmd2.Parameters
                     .Add(new SqlParameter("@e", SqlDbType.NVarChar))
                     .Value = _email;
                 cmd2.Parameters
                     .Add(new SqlParameter("@c", SqlDbType.NVarChar))
                     .Value = _username;
                 cn.Open();
                 cmd2.ExecuteNonQuery();
                 var mongo = new Mongo();
                 var config = mongo.GetUserConfiguration(_username);
                 if (config.AccountInfoNotification)
                 {
                     MailgunAgent.SendChangeEmail(_email, "Your Queue View email has been updated.");
                 }
                 return EmailUpdateStatus.Changed;
             }
         }
         else
         {
             return EmailUpdateStatus.Same;
         }
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return EmailUpdateStatus.Error;
     }
 }
Esempio n. 14
0
 /// <summary>
 /// Changes password
 /// </summary>
 /// <returns>true if success</returns>
 public bool SubmitSupportTicket(SupportTicket ticketData, string username)
 {
     try
     {
         //Write Ticket to MongoDB
         Mongo MongoWrite = new Mongo();
         if (!string.IsNullOrEmpty(username))
         {
             var config = MongoWrite.GetUserConfiguration(username);
             if (config.ClosedTicketNotification)
             {
                 MailgunAgent.SendChangeEmail(GetCurrentEmail(username), "You have created a support ticket on the Queue View.");
             }
         }
         MongoWrite.WriteTicketData(ticketData);
         return true;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return false;
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Saves SMS entry
 /// </summary>
 public void SaveSMSEntry(SMSEntry entry, DateTime? billingDate)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.SaveEntry(entry, billingDate);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Gets User Configuration
 /// </summary>
 /// <returns>UserConfiguration</returns>
 public UserConfiguration GetUserConfiguration(string Username)
 {
     try
     {
         //Get Configs from MongoDB
         Mongo MongoWrite = new Mongo();
         return MongoWrite.GetUserConfiguration(Username);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return null;
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Rolls SMS usage
 /// </summary>
 public void RollSMSEntry(string username, DateTime? billingDate)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.RollUsage(username, billingDate);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 18
0
 /// <summary>
 /// Checks Usage
 /// </summary>
 public bool CheckUsage(string username, DateTime? billingDate)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         return MongoWrite.CheckUsage(username, billingDate, GetCurrentEmail(username));
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
     return false;
 }
Esempio n. 19
0
 /// <summary>
 /// Saves/Updates Notifications
 /// </summary>
 /// <returns>true if success</returns>
 public bool SaveNotifications(UserConfiguration configData)
 {
     try
     {
         //Write Configs to MongoDB
         Mongo MongoWrite = new Mongo();
         return MongoWrite.UpdateUserConfiguration(configData);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return false;
     }
 }
Esempio n. 20
0
 /// <summary>
 /// Create inital config and usage documents
 /// </summary>
 public void CreateIntialMongoDocs(string username, string plan)
 {
     try
     {
         Mongo MongoWrite = new Mongo();
         MongoWrite.CreateIntialMongoDocs(username, GetBillingDate(username), plan);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Checks if email exists in database
 /// </summary>
 /// <param name="_email">User name</param>
 /// <returns>PasswordResetInfo</returns>
 public PasswordResetInfo CreateKeyAndTable(string _email)
 {
     try
     {
         var token = new PasswordResetInfo();
         //24 hour expiration
         token.Expiration = DateTimeOffset.Now.AddHours(24);
         token.Redeemed = false;
         //Get UserID based on validated email
         using (var cn = new SqlConnection(@"Data Source=(LocalDB)"))
         {
             string _sql = @"SELECT [Id] FROM [dbo].[System_Users] " + @"WHERE [Email] = @e";
             var cmd = new SqlCommand(_sql, cn);
             cmd.Parameters
                 .Add(new SqlParameter("@e", SqlDbType.NVarChar))
                 .Value = _email;
             cn.Open();
             var reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 token.CustomerId = reader[0].ToString();
             }
         }
         //Get hash
         using (var rng = new RNGCryptoServiceProvider())
         {
             byte[] data = new byte[4];
             rng.GetBytes(data);
             token.ResetHash = BitConverter.ToInt32(data, 0);
         }
         Mongo MongoWrite = new Mongo();
         MongoWrite.WritePasswordResetData(token);
         return token;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return null;
     }
 }
Esempio n. 22
0
 public List<SMSEntry> GetUsageData(string username, DateTime to, DateTime from)
 {
     try
     {
         //Read Messages from MongoDB
         Mongo MongoRead = new Mongo();
         return MongoRead.GetMessages(username, to, from);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return null;
     }
 }