コード例 #1
0
        public ServiceMutation()
        {
            Field <NonNullGraphType <ServiceType> >(
                _Creation,
                "Tạo và trả về một dịch vụ mới",
                _InputArgument <ServiceCreateInput>(),
                _CheckPermission_TaskObject(
                    p => p.PermissionManageService,
                    context => ServiceBusiness.Add(_GetInput(context))
                    )
                );

            Field <NonNullGraphType <ServiceType> >(
                _Updation,
                "Cập nhật và trả về một dịch vụ mới cập nhật",
                _InputArgument <ServiceUpdateInput>(),
                _CheckPermission_TaskObject(
                    p => p.PermissionManageService,
                    context => ServiceBusiness.Update(_GetInput(context))
                    )
                );

            Field <NonNullGraphType <StringGraphType> >(
                _Deletion,
                "Xóa một dịch vụ",
                _IdArgument(),
                _CheckPermission_String(
                    p => p.PermissionManageService,
                    context =>
            {
                ServiceBusiness.Delete(_GetId <int>(context));
                return("Xóa thành công");
            }
                    )
                );

            Field <NonNullGraphType <StringGraphType> >(
                "SetIsActiveService",
                "Cập nhật trạng thái của dịch vụ",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            },
                    new QueryArgument <NonNullGraphType <BooleanGraphType> > {
                Name = "isActive"
            }
                    ),
                _CheckPermission_String(
                    p => p.PermissionManageService,
                    context =>
            {
                var serviceId = context.GetArgument <int>("id");
                var isActive  = context.GetArgument <bool>("isActive");

                ServiceBusiness.SetIsActive(serviceId, isActive);
                return("Thành công");
            }
                    )
                );
        }
コード例 #2
0
        private void repositoryItemDelete_Click(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle == GridControl.NewItemRowHandle)
            {
                return;
            }

            if (XtraMessageBox.Show(this, "Bạn chắc chắn xóa dòng này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                var row = gridView1.GetFocusedDataRow();

                bool result = serviceBusiness.Delete((int)row["ServiceID"]);
                if (result)
                {
                    gridView1.DeleteSelectedRows();
                }
                else
                {
                    XtraMessageBox.Show(this, "Xóa thất bại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }