public void AddSystemMail(string title, string message, string toUserName, string fromUserName) { const string systemUserName = "******"; var mail = new InternalMail { UserName = systemUserName, PersonName = systemUserName, Title = title, Body = $"<h3>{message}</h3>", SendTime = DateTime.Now, MailType = MailType.系统, CreateUser = fromUserName, UpdateUser = fromUserName, CreateTime = DateTime.Now, UpdateTime = DateTime.Now, LastAction = "发送", Tos = new List <InternalMailTo> { new InternalMailTo { UserName = toUserName, PersonName = toUserName, CreateUser = fromUserName, UpdateUser = fromUserName, CreateTime = DateTime.Now, UpdateTime = DateTime.Now, LastAction = "发送" } } }; _internalMailRepository.Add(mail); }
public ActionResult DeleteConfirmed(int id) { InternalMail internalMail = db.InternalMails.Find(id); db.InternalMails.Remove(internalMail); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,TimeOfCreation,Subject,Message,From,UserId,AttachmentFile,IsRead,Archive,Spam")] InternalMail internalMail) { if (ModelState.IsValid) { db.InternalMails.Add(internalMail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Name", internalMail.UserId); return(View(internalMail)); }
// GET: InternalMails/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InternalMail internalMail = db.InternalMails.Find(id); if (internalMail == null) { return(HttpNotFound()); } return(View(internalMail)); }
// GET: InternalMails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InternalMail internalMail = db.InternalMails.Find(id); if (internalMail == null) { return(HttpNotFound()); } ViewBag.UserId = new SelectList(db.Users, "Id", "Name", internalMail.UserId); return(View(internalMail)); }