Hi , i'm new with serenity and i have one issue/doubt..
I have a grid who has all reserves of differents books from students, and when you click the checkbox in the row, it should enable my button 'APPROVE RETURN'.
Example:

My doubt is :
METHOD in xxxRepository:
`public SaveResponse Update(IUnitOfWork uow, SaveRequest
{
foreach (var libroId2 in request.Entity.LibrosList)
{
var rep = new LibrosRepository();
var request2 = new RetrieveRequest() { EntityId = libroId2 };
RetrieveResponse<Entities.LibrosRow> libroResult = rep.Retrieve(uow.Connection, request2);
libroResult.Entity.Reservado = false;
SaveRequest<Entities.LibrosRow> saveRequest = new SaveRequest<Entities.LibrosRow>();
saveRequest.Entity = libroResult.Entity;
rep.Update(uow, saveRequest);
}
request.Entity.FechaDevolucion = System.DateTime.Now;
return new MySaveHandler().Process(uow, request, SaveRequestType.Update);
}`
OnClick method:
`protected getButtons(): Serenity.ToolButton[]
{
var buttons = super.getButtons();
buttons.push({
title: 'Approve Test Button',
cssClass: 'approve-button',
onClick: () => {
/ /How i call the update method here?
}
})`
If it's not clear, please tell me so i try to explain better.
Thanks.
The repository is only accessible on the server side. Its access from the client side must be done by the Service class.
This class is generated by the xxxEndpoint.cs file (the generation of T4 will transpile it in your /Imports/ServerTypings/xxxService.ts).
If you look at its content, you will see that its methods are almost identical to the Repository, moreover, they call the Repository methods.
To use them on the client side, in your OnClick event, for example, you have call examples in the following file:
/Modules/Administration/RolePermission/RolePermissionDialogs.ts
Look this line :
click: e => {
RolePermissionService.Update({
RoleID: this.options.roleID,
Permissions: this.permissions.value.map(x => x.PermissionKey),
Module: null,
Submodule: null
}, response => {
this.dialogClose();
window.setTimeout(() => Q.notifySuccess(Q.text('Site.RolePermissionDialog.SaveSuccess')), 0);
});
Here we call the Update method of the RolePermissionService class on the client side. This is an interface to the RolePermissionEndpoint class on the server side.
The Update Method of RolePermissionEndpoint will call the Update method of RolePermissionRepository.cs
In this way, you do not have to worry about the Unit Of Work that will be implemented by the Serenity classes.
I invite you to also look at the documentation:
https://volkanceylan.gitbooks.io/serenity-guide/services/service_endpoints.html
https://volkanceylan.gitbooks.io/serenity-guide/services/list_request_handler.html
Best regards
Thanks for the help @Doomisateur , i'll try it .
Most helpful comment
The repository is only accessible on the server side. Its access from the client side must be done by the Service class.
This class is generated by the xxxEndpoint.cs file (the generation of T4 will transpile it in your /Imports/ServerTypings/xxxService.ts).
If you look at its content, you will see that its methods are almost identical to the Repository, moreover, they call the Repository methods.
To use them on the client side, in your OnClick event, for example, you have call examples in the following file:
/Modules/Administration/RolePermission/RolePermissionDialogs.ts
Look this line :
click: e => { RolePermissionService.Update({ RoleID: this.options.roleID, Permissions: this.permissions.value.map(x => x.PermissionKey), Module: null, Submodule: null }, response => { this.dialogClose(); window.setTimeout(() => Q.notifySuccess(Q.text('Site.RolePermissionDialog.SaveSuccess')), 0); });Here we call the Update method of the RolePermissionService class on the client side. This is an interface to the RolePermissionEndpoint class on the server side.
The Update Method of RolePermissionEndpoint will call the Update method of RolePermissionRepository.cs
In this way, you do not have to worry about the Unit Of Work that will be implemented by the Serenity classes.
I invite you to also look at the documentation:
https://volkanceylan.gitbooks.io/serenity-guide/services/service_endpoints.html
https://volkanceylan.gitbooks.io/serenity-guide/services/list_request_handler.html
Best regards