Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Cate,Subject,Contents,RegDate")] Manage manage)
        {
            if (ModelState.IsValid)
            {
                _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));
        }
        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 RedirectToAction(nameof(Index));
            }
            return(View());
        }