public async Task <IActionResult> RoleMenuData_Delete(int Id) { var model = new RoleMenuDataModel(); try { model.Error = await f.RoleMenuData_Del(Id); if (model.Error.MessageStatus == "success") { model.Error = null; return(await Task.Run(() => Json(new { isValid = true }))); } else { model.ListData = await f.RoleMenuData_Get(); return(await Task.Run(() => Json(new { isValid = false, message = model.Error.MessageContent, title = model.Error.MessageTitle, html = Helper.RenderRazorViewToString(this, "RoleMenuData_Table", model) }))); } } catch (Exception ex) { var r = new ErrorViewModel(); r.MessageContent = ex.ToString(); r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = r; return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle, html = Helper.RenderRazorViewToString(this, "RoleMenuData_Table", model) }))); } }
public async Task <IActionResult> RoleMenuData_Search([Bind("IdRole,IdModule,Posisi,IdParent,Urutan,IdMenu")] RoleMenuData data) { var model = new RoleMenuDataModel(); var r = new ErrorViewModel(); if (ModelState.IsValid) { try { model.ListData = await f.RoleMenuData_GetSearch(data); return(await Task.Run(() => Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "RoleMenuData_Table", model) }))); } catch (Exception ex) { r.MessageContent = ex.ToString(); r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = r; model.ListData = await f.RoleMenuData_Get(); return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle, html = Helper.RenderRazorViewToString(this, "RoleMenuData_Table", data) }))); } } else { r.MessageContent = "State Model tidak valid"; r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = r; model.ListData = await f.RoleMenuData_Get(); return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle, html = Helper.RenderRazorViewToString(this, "RoleMenuData_Table", model) }))); } }
public async Task <IActionResult> UserAkses_Delete(int Id) { var model = new RoleMenuDataModel(); try { model.Error = await f.UserData_Del(Id); if (model.Error.MessageStatus == "success") { model.Error = null; return(await Task.Run(() => Json(new { isValid = true }))); } else { return(await Task.Run(() => Json(new { isValid = false, message = model.Error.MessageContent, title = model.Error.MessageTitle }))); } } catch (Exception ex) { var r = new ErrorViewModel(); r.MessageContent = ex.ToString(); r.MessageTitle = "Error "; r.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; return(await Task.Run(() => Json(new { isValid = false, message = r.MessageContent, title = r.MessageTitle }))); } }
public async Task <IActionResult> RoleMenuData() { Config.ConStr = _configuration.GetConnectionString("Db"); var model = new RoleMenuDataModel(); try { DeviceDetector.SetVersionTruncation(VersionTruncation.VERSION_TRUNCATION_NONE); BotParser botParser = new BotParser(); var userAgent = Request.Headers["User-Agent"]; var result = DeviceDetector.GetInfoFromUserAgent(userAgent); if (string.IsNullOrEmpty(HttpContext.Session.GetString("_UserId"))) { var model2 = new alertLogin(); return(await Task.Run(() => RedirectToAction("SignIn", "Home", model2))); } else { ViewBag.UserId = HttpContext.Session.GetString("_UserId"); ViewBag.Device = result.Match.DeviceType.ToString(); Console.WriteLine(ViewBag.Device); var search = new RoleMenuData(); model.ListData = await f.RoleMenuData_GetSearch(search); return(await Task.Run(() => View(model))); } } catch (Exception ex) { var Error = new ErrorViewModel(); Error.MessageContent = ex.ToString(); Error.MessageTitle = "Error "; Error.RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; model.Error = Error; return(await Task.Run(() => View(model))); } }