Beispiel #1
0
        public void StatusPostComment(string currentUserUserName, long streamId, string statusCommentMessage)
        {
            // Below we
            // 1. Notify the stream creator of the comment
            // 2. Notify those that have commented already on the stream (exclude the current comment submitter)

            //Grab the UserId of the stream creator
            var stream = new StreamRepository().GetStream(streamId);

            // Get the stream owner firstname & email address
            string statusOwnerFirstName    = UserHelpers.GetFirstName(stream.StreamCreatorUserId);
            string statusOwnerEmailAddress = UserHelpers.GetUserEmailAddress(stream.StreamCreatorUserId);

            // Get a list of users who have commented on this status
            var commentatorsAdresses = new StreamCommentRepository().GetStatusCommentatorsEmailAddresses(streamId);

            // remove the current user from the list of commentatos since notifiying him would be redundant
            commentatorsAdresses.Remove(currentUserUserName); //FYI: EmailAddress is reused as the username in this app.

            string commenterFirstName = UserHelpers.GetFirstName(currentUserUserName);

            // Compose email
            string applicationUrl = GetCustomApplicationUrl(true, true, true, "");

            string emailMsg = ReadTemplateFile("~/Content/Templates/StatusPostComment.htm");

            emailMsg = emailMsg.Replace("{StatusCommenterFirstName}", commenterFirstName);
            emailMsg = emailMsg.Replace("{StatusMessage}", statusCommentMessage);
            emailMsg = emailMsg.Replace("{StreamId}", streamId.ToString());
            emailMsg = emailMsg.Replace("{ApplicationUrl}", applicationUrl);

            MailMessage message = new MailMessage();

            message.From = new MailAddress(NotificationEmailAddressFrom, "Make progress every day");

            foreach (string emailAddress in commentatorsAdresses)
            {
                message.To.Add(emailAddress);
            }

            message.Subject      = commenterFirstName + "- commented on status";
            message.Body         = emailMsg;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml   = true;

            SendEmail(message);
        }
Beispiel #2
0
        public ActionResult PostToCoWorkerStreamComment(Guid id, int replyToStreamId, FormCollection formCollection)
        {
            if (string.IsNullOrEmpty(formCollection["StreamCommentDetails"]))
            {
                TempData["errorMessage"] = "Yikes! Seems like you forgot to provide us with your valuable thoughts in the comments field. How about you try again?";
                return(RedirectToAction("Wall", "Home", new { id = id }));
            }

            StreamCommentRepository streamCommentRepository = new StreamCommentRepository();
            StreamComment           streamComment           = new StreamComment();

            streamComment.StreamId                       = replyToStreamId;
            streamComment.StreamCommentDetails           = formCollection["StreamCommentDetails"];
            streamComment.StreamCommentSubmitterUserId   = UserHelpers.GetUserId(User.Identity.Name);
            streamComment.StreamCommentSubmitterFullName = UserHelpers.GetUserFullName(User.Identity.Name);
            streamComment.StreamCommentTimeStamp         = DateTime.UtcNow;
            streamCommentRepository.Add(streamComment);
            streamCommentRepository.Save();

            //  TempData["message"] = "Your input was posted to " + streamComment.StreamCommentSubmitterFullName + " wall. We even went as far as notifiying the appropiate parties!.";
            return(RedirectToAction("Profile", "Home", new { id = id }));
        }