public async Task <IActionResult> Create([Bind("UserName,Password,Name,CreateTime")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public IActionResult Tweet(Tweets tweets) { tweets.UserName = HttpContext.Session.GetString("UserName"); tweets.User = (from s in _context.Users where s.UserName == tweets.UserName select s).FirstOrDefault <User>(); tweets.UsName = tweets.User.Name; _context.Add(tweets); tweets.UserName = "******" + HttpContext.Session.GetString("UserName"); tweets.ProfilePicture = tweets.User.ProfilePicture; Response.Cookies.Append("LastLoggedInTime", DateTime.Now.ToString()); _context.SaveChanges(); return(RedirectToAction("Index")); }