Example #1
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);
     }
 }
Example #2
0
 /// <summary>
 /// Save SMS Entry
 /// </summary>
 public void SaveEntry(SMSEntry entry, DateTime? billingDate)
 {
     try
     {
         var mongoDatabase = MongoConnection.Connect();
         mongoDatabase.GetCollection<SMSEntry>(SMSCollection).Insert(entry);
         var existing = mongoDatabase.GetCollection<CustomerUsage>(UsageCollection).FindAllAs<CustomerUsage>().Where(p => p.Username == entry.UserName).FirstOrDefault();
         if (existing.BillingDate < billingDate)
         {
             existing.BillingDate = (DateTime)billingDate;
             existing.TotalSent++;
             existing.SentThisCycle = 1;
             existing.NotificationDate = null;
             mongoDatabase.GetCollection<CustomerUsage>(UsageCollection).Save(existing);
         }
         else if (existing.BillingDate == billingDate)
         {
             existing.TotalSent++;
             existing.SentThisCycle++;
             mongoDatabase.GetCollection<CustomerUsage>(UsageCollection).Save(existing);
         }
     }
     catch (Exception ex)
     {
         Logger.WriteErrorLog(ex);
     }
 }
Example #3
0
 public ActionResult SendMessage()
 {
     User user = new User();
     if (!user.CheckUsage(User.Identity.Name, GetBillingDate(user)))
     {
         //Max messages used
         return new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError);
     }
     SMSEntry entry = new SMSEntry();
     user.UpdateSend(User.Identity.Name, Convert.ToInt32(Request.Form["Position"]));
     entry.Time = DateTimeOffset.Now;
     entry.Number = Request.Form["Phone"];
     entry.UserName = User.Identity.Name;
     user.SaveSMSEntry(entry, GetBillingDate(user));
     user.ExecuteTwilioSMS(Request.Form["Phone"], Request.Form["Message"], user.GetCompany(User.Identity.Name));
     return new HttpStatusCodeResult(System.Net.HttpStatusCode.OK);
 }