public async Task <IActionResult> Create([Bind("PovinceId,PovinceName")] Povince povince) {/*Check Session */ var page = "165"; var typeofuser = ""; var PermisionAction = ""; // CheckSession if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username"))) { Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error); return(RedirectToAction("Index", "Home")); } else { typeofuser = HttpContext.Session.GetString("TypeOfUserId"); PermisionAction = HttpContext.Session.GetString("PermisionAction"); if (PermisionHelper.CheckPermision(typeofuser, PermisionAction, page) == false) { Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error); return(RedirectToAction("Index", "Home")); } } /*Check Session */ if (ModelState.IsValid) { _context.Add(povince); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(povince)); }
public async Task <IActionResult> Edit([Bind("PovinceId,PovinceName")] Povince povince) { /*Check Session */ var page = "166"; var typeofuser = ""; var PermisionAction = ""; // CheckSession if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username"))) { Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error); return(RedirectToAction("Index", "Home")); } else { typeofuser = HttpContext.Session.GetString("TypeOfUserId"); PermisionAction = HttpContext.Session.GetString("PermisionAction"); if (PermisionHelper.CheckPermision(typeofuser, PermisionAction, page) == false) { Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error); return(RedirectToAction("Index", "Home")); } } /*Check Session */ if (ModelState.IsValid) { try { _context.Update(povince); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PovinceExists(povince.PovinceId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(RedirectToAction("Index", "Home")); }