public ActionResult GetStudentContacts() { ComposeViewModel compose = new ComposeViewModel(); compose.StudentContacts = _studentctx.GetContacts(); return(PartialView("~/Views/_Lecturer/Contact/_ContactItem.cshtml", compose)); }
private void btnSend_Click(object sender, RoutedEventArgs e) { ComposeViewModel composeView = new ComposeViewModel(); composeView.ComposeMail(txtboxMessage.Text, txtboxAddress.Text, txtboxSubject.Text); Close(); }
public virtual ActionResult Compose(string username, string title) { var model = new ComposeViewModel(); if (username.HasValue()) { model.UserName = HtmlUtilities.Safe(Server.UrlDecode(username)); } if (title.HasValue()) { model.Subject = HtmlUtilities.Safe(Server.UrlDecode(title).TruncateWithEllipsis(100)); } return(View(model)); }
public async Task <ActionResult> Send(ComposeViewModel model, string messageText) { switch (model.typetosend) { case "1": await new EmailService().sendEmailToContacts(model.recipients, model.subject, model.content); break; case "2": new SmsService().sendSms(messageText, model.recipients); break; } return(Redirect("/#contact")); }
public static ComposeViewModel ComposeForward(int MsgId, RenderContext context) { ComposeViewModel model = new ComposeViewModel(); var maildb = Kooboo.Mail.Factory.DBFactory.UserMailDb(context.User); var msg = maildb.Messages.Get(MsgId); model.Subject = msg.Subject; // model.Attachments = msg.Attachments; model.From = msg.AddressId; if (!model.Subject.ToLower().StartsWith("fw:")) { model.Subject = "Fw:" + model.Subject; } model.Html = ComposeRefMsg(MsgId, context); return(model); }
public static ComposeViewModel ComposeReply(int MsgId, RenderContext context) { ComposeViewModel model = new ComposeViewModel(); var maildb = Kooboo.Mail.Factory.DBFactory.UserMailDb(context.User); var msg = maildb.Messages.Get(MsgId); model.Subject = msg.Subject; model.From = msg.AddressId; if (model.Subject == null) { model.Subject = "Re:"; } if (!model.Subject.ToLower().StartsWith("re:")) { model.Subject = "Re:" + model.Subject; } var msgbody = maildb.MsgBody.Get(msg.BodyPosition); var mime = MessageUtility.ParseMineMessage(msgbody); model.Html = ComposeRefMsg(mime, context, MsgId); var replyto = GetHeader(mime, "reply-to"); if (string.IsNullOrEmpty(replyto)) { replyto = msg.MailFrom; } if (msg.FolderId != Folder.ToId("Sent")) { model.To.Add(Utility.AddressUtility.GetAddress(replyto)); } return(model); }
public virtual ActionResult Compose(ComposeViewModel data) { var db = Current.DB; var currentTime = DateTime.Now; var message = new Message(); var conversation = new Conversation(); // Sender IDs message.SenderID = Current.UserID.Value; conversation.User1 = Current.UserID.Value; message.Date = currentTime; message.IsUnread = true; message.NumberInConvo = 1; conversation.LastMessageDate = currentTime; conversation.StartDate = currentTime; conversation.Subject = HtmlUtilities.Safe(data.Subject.TruncateWithEllipsis(100)); // Look up other user var otherUserObj = Membership.FindUsersByName(data.UserName)[data.UserName]; if (otherUserObj == null) { ModelState.AddModelError("UserName", "Invalid user"); return(View(data)); } var otherUser = (Guid)otherUserObj.ProviderUserKey; message.ReceipientID = otherUser; conversation.User2 = otherUser; // Handle markdown message.Markdown = HtmlUtilities.Sanitize(data.Markdown); message.Html = HtmlUtilities.Safe(HtmlUtilities.RawToCooked(message.Markdown)); // Submit try { db.Conversations.InsertOnSubmit(conversation); //An exception will be thrown here if there are invalid properties db.SubmitChanges(); message.ConversationID = conversation.ConversationID; db.Messages.InsertOnSubmit(message); db.SubmitChanges(); } catch (Exception ex) { // Yikes Elmah.ErrorSignal.FromCurrentContext().Raise(ex, Current.Context); return(RedirectToAction("InternalServerError", "Error")); } // Global Post: var gpostconversation = new GlobalPostID(); gpostconversation.UserID = Current.UserID.Value; gpostconversation.PostCategory = MagicCategoryStrings.Conversation; gpostconversation.SubmissionDate = currentTime; gpostconversation.SpecificPostID = conversation.ConversationID; db.GlobalPostIDs.InsertOnSubmit(gpostconversation); db.SubmitChanges(); conversation.GlobalPostID = gpostconversation.GlobalPostID1; db.SubmitChanges(); var gpostmessage = new GlobalPostID(); gpostmessage.UserID = Current.UserID.Value; gpostmessage.PostCategory = MagicCategoryStrings.Message; gpostmessage.SubmissionDate = currentTime; gpostmessage.SpecificPostID = message.MessageID; db.GlobalPostIDs.InsertOnSubmit(gpostmessage); db.SubmitChanges(); message.GlobalPostID = gpostmessage.GlobalPostID1; db.SubmitChanges(); // Notification: new NotificationsController().CreateNotification(otherUser, gpostconversation, currentTime); return(RedirectToAction("Thread", new { id = conversation.ConversationID })); }