Exemple #1
0
 /// <summary>
 /// Create inital config and usage documents
 /// </summary>
 public void CreateIntialMongoDocs(string username, DateTime? billingDate, string plan)
 {
     try
     {
         var mongoDatabase = MongoConnection.Connect();
         CustomerUsage newUsage = new CustomerUsage();
         newUsage.BillingDate = (DateTime)billingDate;
         newUsage.TotalSent = 0;
         newUsage.NotificationDate = null;
         newUsage.SentThisCycle = 0;
         newUsage.PlanLimit = 6000;
         newUsage.Username = username;
         mongoDatabase.GetCollection<CustomerUsage>(UsageCollection).Insert(newUsage);
         UserConfiguration config = new UserConfiguration();
         config.Username = username;
         config.ShowNotes = true;
         config.ShowDeletePrompt = true;
         config.AccountInfoNotification = true;
         config.ClosedTicketNotification = true;
         config.SmsNotification = true;
         config.Message = "Another message from The Queue View";
         mongoDatabase.GetCollection<UserConfiguration>(UserConfigurationCollection).Insert(config);
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Exemple #2
0
 /// <summary>
 /// use to write user configuration objects to mongo DB
 /// </summary>
 /// <returns>true if successful</returns>
 public bool WriteUserConfiguration(UserConfiguration configData)
 {
     try
     {
         //Write object to Mongo DB Collection
         var mongoDatabase = MongoConnection.Connect();
         var existing = mongoDatabase.GetCollection<UserConfiguration>(UserConfigurationCollection).FindAllAs<UserConfiguration>().Where(p => p.Username == configData.Username).FirstOrDefault();
         if (existing == null)
         {
             mongoDatabase.GetCollection<UserConfiguration>(UserConfigurationCollection).Insert(configData);
         }
         else
         {
             if (configData.Message == null)
             {
                 configData.Message = existing.Message;
             }
             else
             {
                 configData.ShowDeletePrompt = existing.ShowDeletePrompt;
                 configData.ShowNotes = existing.ShowNotes;
             }
             configData.AccountInfoNotification = existing.AccountInfoNotification;
             configData.ClosedTicketNotification = existing.ClosedTicketNotification;
             configData.SmsNotification = existing.SmsNotification;
             configData._id = existing._id;
             mongoDatabase.GetCollection<UserConfiguration>(UserConfigurationCollection).Save(configData);
         }
         return true;
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
         return false;
     }
 }
Exemple #3
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;
     }
 }
 public ActionResult SaveNotification(UserModel.User user)
 {
     if (ModelState.IsValid)
     {
         var configuration = new UserConfiguration();
         configuration.SmsNotification = user.SmsLimit;
         configuration.ClosedTicketNotification = user.TicketClosed;
         configuration.AccountInfoNotification = user.InformationChange;
         configuration.Username = User.Identity.Name;
         if (!user.SaveNotifications(configuration))
         {
             //Fail
             return RedirectToAction("Error", "User");
         }
     }
     return RedirectToAction("AccountDashboard", "User", new { ADN = "Notification" });
 }
 public ActionResult SaveGeneralConfiguration(UserModel.User user)
 {
     if (ModelState.IsValid)
     {
         var configuration = new UserConfiguration();
         configuration.ShowDeletePrompt = user.ShowDeletePrompt;
         configuration.ShowNotes = user.ShowNotes;
         configuration.Username = User.Identity.Name;
         if (!user.SubmitConfiguration(configuration))
         {
             //Fail
             return RedirectToAction("Error", "User");
         }
     }
     return RedirectToAction("AccountDashboard", "User", new { ADCF = "ChangeConfig" });
 }
 public ActionResult SaveDefaultMessage(UserModel.User user)
 {
     if (ModelState.IsValid)
     {
         var configuration = new UserConfiguration();
         configuration.Message = user.DefaultMessage;
         configuration.Username = User.Identity.Name;
         if (!user.SubmitConfiguration(configuration))
         {
             //Fail
             return RedirectToAction("Error", "User");
         }
     }
     return RedirectToAction("AccountDashboard", "User", new { ADDF = "ChangeMessage" });
 }