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");
        }
Exemple #2
0
        public ActionResult MessageDelete(MessageInfoSummaryViewModel messageInfo)
        {
            var MessageInfo = db.MessageInfo.Find(messageInfo.ID);

            db.MessageInfo.Remove(MessageInfo);
            db.SaveChanges();

            return RedirectToAction("MessageInfo");
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }