public IActionResult AddUserInput(UserInfo userInfo) { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; //checks if the user already has info if (ModelState.IsValid) { DateTime dob = (DateTime)userInfo.Dob; var today = DateTime.Today; var age = today.Year - dob.Year; if (dob.Date > today.AddYears(-age)) { age--; } userInfo.Age = age; userInfo.OwnerId = id; _context.UserInfo.Add(userInfo); _context.SaveChanges(); ViewBag.userName = (string)userInfo.Name; return(RedirectToAction("Index", "Home")); } else { ViewBag.userInfoMessage = "SOMETHING WENT WRONG.... PLEASE MAKE SURE ALL INFORMATION IS ENTERED BELOW...."; return(View("AddUserInput")); } }
public IActionResult UpdateParkVisited(int id) { string Userid = User.FindFirst(ClaimTypes.NameIdentifier).Value; UserParks found = _context.UserParks.Where(x => x.UsersParkIds == id).First(); found.ParkVisited = true; _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(found); _context.SaveChanges(); return(RedirectToAction("parksVisited")); }
public IActionResult MarkAsScheduled(int id) { UserParks found = _context.UserParks.Where(x => x.UsersParkIds == id).First(); found.ParkVisited = null; _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.Update(found); _context.SaveChanges(); return(RedirectToAction("CheckUserPrefs")); }