public static void SendEmail(MailMessage mail, object token, EmailEntityType typeToSave) { try { SmtpClient smtp = new SmtpClient(); smtp.EnableSsl = false; smtp.Send(mail); Console.WriteLine("Completed MessageRecipient.Id:" + token); if (null != token) { if (EmailEntityType.MessageRecipient == typeToSave) { Guid messageRecipientId = new Guid(token.ToString()); MessageRepository msgRepository = new MessageRepository(); Message msg = msgRepository.FindByMessageRecipientId(messageRecipientId); msg.SentDate = DateTime.Now; msgRepository.Save(msg); } else if (EmailEntityType.InnerCircle == typeToSave) { Guid innerCircleId = new Guid(token.ToString()); InnerCircleRepository icRepository = new InnerCircleRepository(); InnerCircle ic = icRepository.GetById(innerCircleId); ic.NotificationSentDate = DateTime.Now; icRepository.Save(ic); } } } catch (Exception ex) { Console.WriteLine("Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); } }
public bool Overlaps(Disk disk) { if (!Overlaps(disk.OuterCircle)) { return(false); } return(!InnerCircle.Contains(disk.OuterCircle) && !disk.InnerCircle.Contains(OuterCircle)); }
public bool Contains(Rect rect) { if (!Bounds.Overlaps(rect)) { return(false); } return(OuterCircle.Contains(rect) && !InnerCircle.Overlaps(rect)); }
public ActionResult Accept(Guid id) { InnerCircle ic = _innerCircleRepository.GetById(id); //Can never turn this off (client-side script disables the checkbox but it could be hacked ic.AcceptedResponsibility = true; // !ic.AcceptedResponsibility; _innerCircleRepository.Save(); return(RedirectToAction("Member")); }
public ActionResult Choose(string email, string firstName, string lastName) { ViewData["ProgressStep"] = "4"; AppUser user = _userRepository.GetByUserName(User.Identity.Name); //By the time we get here, we should be able to assume that the user has chosen how many in their IC short numTrustees = user.Profile.NumberOfTrustees.Value; if (numTrustees <= user.InnerCircle.Count) { ModelState.AddModelError("_FORM", "You have chosen to have " + numTrustees.ToString() + " member(s) in your Inner Circle. There is no need to add any more."); } else if (string.IsNullOrEmpty(email)) { ModelState.AddModelError("email", "Please enter an email address. It is required."); } else { bool hasError = false; Profile profile = _profileRepository.GetByEmail(email); InnerCircle newInnerCircle = _innerCircleRepository.GetByEmailAndUserId(email, user.Id); if (null == profile) { if (string.IsNullOrEmpty(firstName)) { ModelState.AddModelError("firstName", "Please enter a first name. It is required when no profile matches the email address."); hasError = true; } if (string.IsNullOrEmpty(lastName)) { ModelState.AddModelError("lastName", "Please enter a last name. It is required when no profile matches the email address."); hasError = true; } profile = _profileRepository.New(firstName, lastName, String.Empty, email); } if (null == newInnerCircle) { newInnerCircle = _innerCircleRepository.New(); } if (!hasError) { _innerCircleRepository.AddInnerCircleToProfile(newInnerCircle, profile); _innerCircleRepository.AddInnerCircleToUser(newInnerCircle, user); _innerCircleRepository.Save(); } } return(View(new InnerCircleChooseViewModel(user))); }
public ActionResult Delete(Guid id) { InnerCircle chosenOne = null; try { chosenOne = _innerCircleRepository.GetById(id); if (chosenOne == null) { return(View("NotFound")); } _innerCircleRepository.Delete(chosenOne); return(RedirectToAction("Choose")); } catch (Exception) { return(View()); } }
public ActionResult LifeEvent(Guid innerCircleId, Guid eventType, DateTime eventDate) { InnerCircle ic = _innerCircleRepository.GetById(innerCircleId); //TODO: Business Rules should be relocated InnerCircleAction existingIca = _innerCircleActionRepository.GetByInnerCircleAndUserNameAndEventTypeId(ic, User.Identity.Name, eventType); if (null != existingIca) { ModelState.AddModelError("_FORM", "Thanks, but we already have a record of you notifying us of this event. You notified us on " + String.Format("{0:d}", existingIca.ActionDate)); AppUser user = _userRepository.GetByUserName(User.Identity.Name); return(View("Member", new InnerCircleMemberViewModel(user))); } //if a trustee is notifying viternus of a life event, then he/she has accepted responsibility ic.AcceptedResponsibility = true; InnerCircleAction ica = _innerCircleActionRepository.New(); _innerCircleActionRepository.AddInnerCircleActionToEventType(ica, eventType); ica.EventDate = eventDate; ica.ActionDate = DateTime.Now; _innerCircleActionRepository.AddInnerCircleActionToInnerCircle(ica, ic); //TODO: Why am I just using the last entered Event Date? if ("Incapacitation" == ica.EventType.Description && ic.MajorityIncapacitated) { ic.AppUser.Profile.IncapacitationDate = eventDate; } else if ("Death" == ica.EventType.Description && ic.MajorityDeceased) { ic.AppUser.Profile.DeceasedDate = eventDate; } _innerCircleActionRepository.Save(); return(RedirectToAction("Member")); }
internal static MailMessage GenerateInnerCircleRequestEmail(InnerCircle trustee) { Console.WriteLine(String.Format("Sending an e-mail to {0} at {1}{2}", trustee.Profile.FirstName, trustee.Profile.Email, Environment.NewLine)); try { MailMessage mail = new MailMessage(); string firstName = trustee.AppUser.Profile.FirstName; string lastName = trustee.AppUser.Profile.LastName; if (!String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName)) { mail.From = new MailAddress("*****@*****.**", string.Format("{0} {1}", firstName, lastName)); } if (!string.IsNullOrEmpty(trustee.Profile.Email)) { mail.To.Add(trustee.Profile.Email); } if (!string.IsNullOrEmpty(trustee.Profile.EmailAlternate)) { mail.To.Add(trustee.Profile.EmailAlternate); } mail.Subject = "You have been designated as a trustee"; mail.IsBodyHtml = false; StringBuilder body = new StringBuilder(); body.Append("Dear "); body.Append(String.IsNullOrEmpty(trustee.Profile.FirstName) ? "Trustee" : trustee.Profile.FirstName); body.Append(","); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append(firstName); body.Append(" "); body.Append(lastName); body.Append(" listed you as a Trustee in the Inner Circle."); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("With this designation comes the following responsibility:"); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("- Immediate Action Required: Create your free account on Viternus.com"); body.Append(Environment.NewLine); body.Append("- Immediate Action Required: Accept the responsiblity of being a trustee"); body.Append(Environment.NewLine); body.Append("- Future Action Required: Should something happen to " + firstName + ", such as incapacitation or death, log in and notify Viternus via the 'I am a Trustee' link."); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append(Environment.NewLine); //TODO: Right now we always assume the Inner Circle member needs a new account body.Append("To fulfill your responsibility, click the link below and create your account:"); body.Append(Environment.NewLine); body.Append(@"http://www.Viternus.com/Account/Register?email=" + trustee.Profile.Email + "&userName="******"&ReturnUrl=%2fInnerCircle%2fMember"); body.Append(Environment.NewLine); body.Append(Environment.NewLine); body.Append("Thank you,"); body.Append(Environment.NewLine); body.Append("Viternus Webmaster"); mail.Body = body.ToString(); return(mail); } catch (Exception ex) { Console.WriteLine("Error" + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace); ErrorLogRepository errorRepos = new ErrorLogRepository(); errorRepos.SaveErrorToDB(ex, "GenerateInnerCircleRequestEmail failed", String.Empty); return(null); } }