public ActionResult MsgAdmin(MessageToAdmin msg)
 {
     if (ModelState.IsValid)
     {
         db.Messages.Add(msg);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(msg));
 }
Ejemplo n.º 2
0
        public ActionResult ContactToAdmin(MessageToAdmin userMessageToAdmin)
        {
            if (Session["UserId"] != null)
            {
                userMessageToAdmin.UserName = Session["Username"].ToString();
                userMessageToAdmin.UserId   = Convert.ToInt32(Session["UserId"]);
            }
            userMessageToAdmin.UserName = "******";
            userMessageToAdmin.Time     = DateTime.Now;

            if (ModelState.IsValid)
            {
                db.TblFromUser.Add(userMessageToAdmin);
                db.SaveChanges();
                if (Session["UserId"] != null)
                {
                    return(RedirectToAction("UserHome", "Post"));
                }
                return(RedirectToAction("Home", "Post"));
            }

            return(View(userMessageToAdmin));
        }