예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,content,mail")] Message message)
        {
            if (ModelState.IsValid)
            {
                _context.Add(message);
                await _context.SaveChangesAsync();

                return(View("sended"));
            }
            return(View(message));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Password")] User user)
        {
            if (HttpContext.Session.GetString("user") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            else
            {
                TempData["user"] = "******";
            }
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,PublishDate,Title,BodyText")] Post post)
        {
            if (HttpContext.Session.GetString("user") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            else
            {
                TempData["user"] = "******";
            }

            if (ModelState.IsValid)
            {
                _context.Add(post);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(post));
        }