public ActionResult UpdatePermission(GroupRole groupRole) { // kiểm tra quền đã được gán hay chưa if (_groupRole.GetAll().Any(x => x.GroupId == groupRole.GroupId && x.BusinessId == groupRole.BusinessId && x.RoleId == groupRole.RoleId)) { // nếu có thì xóa (hủy quên) // lấy đối tượng cần xóa var obj = _groupRole.GetAll().FirstOrDefault(x => x.GroupId == groupRole.GroupId && x.BusinessId == groupRole.BusinessId && x.RoleId == groupRole.RoleId); _groupRole.DeleteEntity(obj); return(Json(new { Status = 200, Message = "Successfully canceled" }, JsonRequestBehavior.AllowGet));; } else { _groupRole.Create(groupRole); return(Json(new { Status = 200, Message = "Successful assignment" }, JsonRequestBehavior.AllowGet)); } }