public ActionResult Login(User user) { var data = _Context.Users.Where(a => a.Email == user.Email && a.Password == user.Password).FirstOrDefault(); if (data != null) { TempData["Message"] = data.Name; DateTime date = DateTime.Now; var log = _Context.UserLogs.Where(a => a.Date == date.Date && a.UserId == data.Id).FirstOrDefault(); if (log == null) { UserLog userLog = new UserLog(); userLog.UserId = data.Id; userLog.UserName = data.Name; userLog.Date = date.Date; userLog.Count = 1; _Context.UserLogs.Add(userLog); _Context.SaveChanges(); } else { log.Count = (log.Count + 1); _Context.Update(log); _Context.SaveChanges(); } return(RedirectToAction("Index", "Dashboard")); } ViewBag.Invalid = "Invalid Email & Password..!"; return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Password,Phone,City")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }