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)); }
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)); }
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)); }