public ActionResult Logins(LoginDetail objLogin) { if (ModelState.IsValid) { UserInfosViewModel obj_details = new UserInfosViewModel(); UserBLL obj_detail = new UserBLL(); obj_details = obj_detail.GetDetails(objLogin.Username); if (obj_details != null) { if (obj_details.Password == objLogin.Password) { Session["Fname"] = obj_details.Firstname; Session["Lname"] = obj_details.Lastname; return(RedirectToAction("Home", "User")); } else { return(RedirectToAction("InvalidLogin", "LoginUser")); } } else { return(RedirectToAction("InvalidLogin", "LoginUser")); } } else { return(View("Login")); } }
public UserInfosViewModel GetDetails(string Username) { UserInfos details = userDal.GetUserDetails(Username); UserInfosViewModel userInfoView = new UserInfosViewModel(); if (details != null) { userInfoView.UserId = details.UserId; userInfoView.Username = details.Username; userInfoView.Password = details.Password; userInfoView.Firstname = details.Firstname; userInfoView.Lastname = details.Lastname; return(userInfoView); } else { return(null); } }
public async Task <IActionResult> UserInfos() { var token = GetToken(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!TokenService.ValidateToken(token) || !TokenService.VerifDateExpiration(token)) { return(Unauthorized()); } AuthService service = new AuthService(_context); User user = service.GetUserConnected(token); UserInfosViewModel userInfos = new UserInfosViewModel() { FirstName = user.UserFirstname, LastName = user.UserName, PhoneNumber = user.UserPhone, Email = user.UserEmail, DrivingLicence = user.UserNumpermis, Pole = _context.Pole.Where(p => p.PoleId == user.UserPoleId).First().PoleName, Right = _context.Right.Where(r => r.RightId == user.UserRightId).First().RightLabel, LocationsCount = _context.Location.Where(l => l.LocUserId == user.UserId)?.Count() ?? 0, UrlProfileImage = "" }; Location nextLoc = GetNextLocationByUser(user.UserId); if (nextLoc != null) { userInfos.NextLocation = nextLoc.LocDatestartlocation; userInfos.NextLocationId = nextLoc.LocId; } return(Ok(userInfos)); }