public async Task <IActionResult> Create( [Bind("IdLink,AddDate,Description,LikeCount,LinkURL,UpdateDate,WhoAdd")] Link link) { if (ModelState.IsValid) { link.IdLink = _context.Link.Max(i => i.IdLink) + 1; //W Internecie jest mnóstwo postów, że nie da się zrobić pola autonumber (najpopularniejsza opcja [DatabaseGenerated(DatabaseGeneratedOption.Identity)]) link.AddDate = DateTime.Now; link.UpdateDate = DateTime.Now; link.LikeCount = 0; link.WhoAdd = User.Identity.Name; _context.Add(link); await _context.SaveChangesAsync(); } return(RedirectToAction("Index")); }
public async Task <IActionResult> ConfirmEmail(string userId, string code) { if (userId == null || code == null) { return(RedirectToAction("Index", "Links")); } var user = await _userManager.FindByIdAsync(userId); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{userId}'."); } if (user.EmailConfirmed == false) { user.EmailConfirmed = true; _context.Update(user); await _context.SaveChangesAsync(); return(View("ConfirmEmail", "Users")); } else { return(View("ConfirmEmailDoneBefore", "Users")); } }