public async Task <IActionResult> Create([Bind("AppSuccessId,AppSuccessName")] AppSuccess appSuccess) { /*Check Session */ var page = "145"; 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(appSuccess); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(appSuccess)); }
protected void SendSuccess() { AppSuccess success = Pool.Get <AppSuccess>(); AppResponse appResponse = Pool.Get <AppResponse>(); appResponse.success = success; Send(appResponse); }
public async Task <IActionResult> Edit([Bind("AppSuccessId,AppSuccessName")] AppSuccess appSuccess) { /*Check Session */ var page = "146"; 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(appSuccess); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppSuccessExists(appSuccess.AppSuccessId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(RedirectToAction("Index", "Home")); }