/// <summary> /// ctor the Mighty /// </summary> public BrewSessionCommentEmailMessage(IWebSettings webSettings, BrewSession brewSession, string commenterUsername, UserSummary userToNotify, BrewSessionComment brewSessionComment, BrewgrUrlBuilder brewgrUrlBuilder) : base(webSettings) { this.WebSettings = webSettings; this.BrewSession = brewSession; this.CommenterUsername = commenterUsername; this.UserToNotify = userToNotify; this.BrewSessionComment = brewSessionComment; this.BrewgrUrlBuilder = brewgrUrlBuilder; // Set Sender this.SenderAddress = webSettings.SenderAddress; this.SenderDisplayName = webSettings.SenderDisplayName; // Set Recipient this.ToRecipients.Add(userToNotify.EmailAddress); // Build Subject if (brewSession.UserId == userToNotify.UserId) { this.Subject = string.Format("{0} commented on your brew session for {1}", commenterUsername, brewSession.RecipeSummary.RecipeName); } else { this.Subject = string.Format("{0} also left a comment on the brew session for {1}", commenterUsername, brewSession.RecipeSummary.RecipeName); } }
public ActionResult AddComment(CommentAddViewModel commentAddViewModel) { if (!commentAddViewModel.Validate().IsValid) { return this.Issue404(); } // Normalize the Line Breaks commentAddViewModel.CommentText = commentAddViewModel.CommentText.Replace("\n", Environment.NewLine); switch (commentAddViewModel.CommentType) { case CommentType.Recipe: RecipeComment recipeComment; using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork()) { recipeComment = new RecipeComment(); recipeComment.CommentText = commentAddViewModel.CommentText; recipeComment.RecipeId = commentAddViewModel.GenericId; this.RecipeService.AddRecipeComment(recipeComment); unitOfWork.Commit(); } // Queue Comment Notification this.NotificationService.QueueNotification(NotificationType.RecipeComment, recipeComment); break; case CommentType.Session: BrewSessionComment brewSessionComment; using (var unitOfWork = this.UnitOfWorkFactory.NewUnitOfWork()) { brewSessionComment = new BrewSessionComment(); brewSessionComment.CommentText = commentAddViewModel.CommentText; brewSessionComment.BrewSessionId = commentAddViewModel.GenericId; this.RecipeService.AddBrewSessionComment(brewSessionComment); unitOfWork.Commit(); } // Queue Comment Notification this.NotificationService.QueueNotification(NotificationType.BrewSessionComment, brewSessionComment); break; default: return this.Issue404(); } var commentViewModel = new CommentViewModel(); commentViewModel.CommentText = commentAddViewModel.CommentText; commentViewModel.UserId = this.ActiveUser.UserId; commentViewModel.UserName = this.ActiveUser.Username; commentViewModel.UserAvatarUrl = UserAvatar.GetAvatar(59, this.ActiveUser.EmailAddress); commentViewModel.DateCreated = DateTime.Now; return View("_Comment", commentViewModel); }