コード例 #1
0
        public async Task <IActionResult> Create([Bind("ID,DateCreated,Name,Email,MessageText")] AdminMessage adminMessage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(adminMessage);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(adminMessage));
        }
コード例 #2
0
        public async Task <IActionResult> Index(IFormCollection values)
        {
            AdminMessage msg = new AdminMessage();

            msg.Name        = values["name"];
            msg.Email       = values["email"];
            msg.MessageText = values["msg"];

            _context.Add(msg);
            await _context.SaveChangesAsync();

            return(View());
        }