/// <summary>
 /// Mails information about a smile to all subscribers, based on both point and organization subscriptions.
 /// </summary>
 /// <param name="smile">Smile to mail for.</param>
 public void mailSmileToSubscribers(Smile smile)
 {
     SendASmile.Mailers.ISmileMailer mail = new SendASmile.Mailers.SmileMailer();
     using (var db = new SmileContext())
     {
         List<MailSub> listOrgs = db.MailSub.Include(p => p.point).Include(o => o.org).Where(o => o.org.orgID == smile.point.organization.orgID).ToList();
         List<MailSub> listPoints = db.MailSub.Include(p => p.point).Include(o => o.org).Where(p => p.point.pointID == smile.point.pointID).ToList();
         foreach (var x in listOrgs)
         {
             if (smile.isSmile)
             {
                 mail.smileLogged(smile, x.email, x.subId).SendAsync();
             }
             else
             {
                 mail.frownLogged(smile, x.email, x.subId).SendAsync();
             }
         }
         foreach (var x in listPoints)
         {
             if (smile.isSmile)
             {
                 mail.smileLogged(smile, x.email, x.subId).SendAsync();
             }
             else
             {
                 mail.frownLogged(smile, x.email, x.subId).SendAsync();
             }
         }
     }
 }
 /// <summary>
 /// Submits a smile based on its properties
 /// </summary>
 /// <param name="pointId"></param>
 /// <param name="subject"></param>
 /// <param name="body"></param>
 /// <param name="email"></param>
 /// <param name="isSmile"></param>
 public Smile submitSmile(int pointId, string subject, string body, string email, bool isSmile)
 {
     Smile smile = new Smile { body = body, subject = subject, contactEmail = email, isSmile = isSmile, DateSubmitted = DateTime.Now, point = new Point() };
     smile.point = db.Point.Include(o => o.organization).Where(p => p.pointID == pointId).First();
     db.Smile.Add(smile);
     db.SaveChanges();
     return smile;
 }
 /// <summary>
 /// Emails subscriber with smile information.
 /// </summary>
 /// <param name="smile">Smile to notify for.</param>
 /// <param name="Email">Email to send to.</param>
 /// <param name="subId">Id of the subscription to mail to.</param>
 /// <returns>Smile report mail message.</returns>
 public virtual MvcMailMessage smileLogged(Smile smile, string Email, int subId)
 {
     ViewBag.subId = subId;
     ViewData.Model = smile;
     return Populate(x =>
     {
         x.Subject = "Smile submitted for " + smile.point.name;
         x.ViewName = "smileLogged";
         x.To.Add(Email);
     });
 }
 /// <summary>
 /// Emails subscriber with frown information.
 /// </summary>
 /// <param name="frown">Smile to notify for.</param>
 /// <param name="Email">Email to send to.</param>
 /// <param name="subId">Id of the subscription to mail to.</param>
 /// <returns>Frown report mail message.</returns>
 public virtual MvcMailMessage frownLogged(Smile frown, string Email, int subId)
 {
     ViewBag.subId = subId;
     ViewData.Model = frown;
     return Populate(x =>
     {
         x.Subject = "Frown Submitted for " + frown.point.name;
         x.ViewName = "frownLogged";
         x.To.Add(Email);
     });
 }
 /// <summary>
 /// Submits a smile object to database
 /// </summary>
 /// <param name="smile"></param>
 public void submitSmile(Smile smile)
 {
     smile.point = db.Point.Include(o => o.organization).Where(p => p.pointID == smile.point.pointID).First();
     db.Smile.Add(smile);
     db.SaveChanges();
 }