public ActionResult MessageSubmit(MessageInfoSummaryViewModel messageInfo) { MessageInfo messages = new MessageInfo { Name = messageInfo.Name, Email = messageInfo.Email, Content = messageInfo.Content, CreateDate = DateTime.Now }; db.MessageInfo.Add(messages); db.SaveChanges(); return RedirectToAction("Contact"); }
public ActionResult MessageDelete(MessageInfoSummaryViewModel messageInfo) { var MessageInfo = db.MessageInfo.Find(messageInfo.ID); db.MessageInfo.Remove(MessageInfo); db.SaveChanges(); return RedirectToAction("MessageInfo"); }
public ActionResult MessageDeleteConfirm(int id) { var MessageInfo = db.MessageInfo.Find(id); MessageInfoSummaryViewModel messageInfo = new MessageInfoSummaryViewModel { Name = MessageInfo.Name, Email = MessageInfo.Email, Content = MessageInfo.Content, CreateDate = MessageInfo.CreateDate.ToString() }; return View(messageInfo); }
public ActionResult MessageInfo() { var messageInfo = db.MessageInfo.ToList(); List<MessageInfoSummaryViewModel> message_sm = new List<MessageInfoSummaryViewModel>(); foreach (var item in messageInfo) { MessageInfoSummaryViewModel _messageInfo = new MessageInfoSummaryViewModel { ID = item.ID, Name = item.Name, Email = item.Email, Content = item.Content, CreateDate = item.CreateDate.ToString() }; message_sm.Add(_messageInfo); } return View(message_sm); }