public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } if (HttpContext.Session.Get("Id") != null) { byte[] str = HttpContext.Session.Get("Id"); string ID = Encoding.UTF8.GetString(str, 0, str.Length); ViewData["Userid"] = ID; } if (HttpContext.Session.Get("Role") != null) { byte[] str = HttpContext.Session.Get("Role"); string Role = Encoding.UTF8.GetString(str, 0, str.Length); ViewData["UserRole"] = Role; } USERS = _context.getUser(id.GetValueOrDefault()); if (USERS == null) { return(NotFound()); } /* * if (USERS.U_Role == "Master") * { * return RedirectToPage("../USERS/Index"); * }*/ return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } USERS = _context.getUser(id.GetValueOrDefault()); if (USERS == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } if (HttpContext.Session.Get("Id") != null) { byte[] str = HttpContext.Session.Get("Id"); string ID = Encoding.UTF8.GetString(str, 0, str.Length); ViewData["Userid"] = ID; } if (HttpContext.Session.Get("Role") != null) { byte[] str = HttpContext.Session.Get("Role"); string Role = Encoding.UTF8.GetString(str, 0, str.Length); ViewData["UserRole"] = Role; } USERS = _context.getUser(id.GetValueOrDefault()); Msg = USERS.U_ID.ToString(); //url = "../Products/Products?id=" + USERS.U_ID; if (USERS == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } USERS = _context.getUser(id.GetValueOrDefault()); if (USERS == null) { return(NotFound()); } if (USERS.U_Role == "Master") { return(RedirectToPage("/USERS/Index")); } return(Page()); }
public async Task <IActionResult> OnGetAsync() { Msg = "Get in the OnPost"; /* * if (int.Parse(Request.Form["ID"]) == 0 || string.IsNullOrEmpty(Request.Form["ID"])) * { * Msg = "ID is empty"; * return Page(); * * } * else * { * if (string.IsNullOrWhiteSpace(Password = Request.Form["Pass"])) * { * * Msg = "Password is empty"; * return Page(); * } * }*/ ID = int.Parse(Request.Form["ID"]); Password = Request.Form["Pass"]; var users = from m in _context.USERS select m; if (ID > 0) { users = users.Where(s => s.U_ID.Equals(ID)); if (users == null) { Msg = "Invalid ID"; } else { Msg = ""; } } USER = _context.getUser(ID); if (!string.IsNullOrWhiteSpace(Password) && !(USER == null)) { if (USER.U_Pass.Contains(Password)) { _context.Userid = ID; if (USER.U_Role.Contains("Customer")) { Msg = "Customer cannot login as Admin"; return(RedirectToPage("./Pages/Index")); } checkPass = true; //return Page(); //This mean admin logged in return(RedirectToPage("./USERS/Index")); } else { checkPass = false; Msg = "Login failed"; return(Page()); } } else { Msg = "Login failed"; return(Page()); } }