public IActionResult UpdateRolePermision(string JsonPost) { var model = JsonConvert.DeserializeObject <List <RoleGroupViewModel> >(JsonPost); var lstRole = new List <RoleGroup>(); var roleId = ""; model.ForEach(x => { var roleGroup = new RoleGroup() { ActionName = x.ActionName, ControllerName = x.ControllerName, RoleId = x.Id, Type = x.PermisionEnumId, }; lstRole.Add(roleGroup); roleId = x.Id; }); if (!string.IsNullOrWhiteSpace(roleId)) { _roleService.DeleteRoleGroups(roleId); } _roleService.InsertRoleGroups(lstRole); return(Json(new { status = true, message = "" })); }