public async Task <IActionResult> Create([Bind("Id,Cate,Subject,Contents,RegDate")] Manage manage)
        {
            if (ModelState.IsValid)
            {
                manage.RegDate = DateTime.Now;
                _context.Add(manage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(manage));
        }
        public async Task <IActionResult> Create([Bind("Subject,Contents,Writer")] Board board)
        {
            if (ModelState.IsValid)
            {
                board.RegDate   = DateTime.Now;
                board.ReadCount = 0;
                _context.Add(board);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(board));
        }
예제 #3
0
        public async Task <IActionResult> Index([Bind("Id,Name,Email,Contents")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    contact.RegDate = DateTime.Now;
                    _context.Add(contact);
                    await _context.SaveChangesAsync();

                    ViewBag.Message = "감사합니다. 연락드리겠습니다.";
                }
                catch (Exception ex)
                {
                    ModelState.Clear();
                    ViewBag.Message = $"예외가 발생했습니다. {ex.Message}";
                }
            }
            return(View());
        }