create database record

Hi there by scheduler in Blazor i need to create a database record. 

in this method OnActionCompleted(Syncfusion.Blazor.Schedule.ActionEventArgs<ActivityAppointment> args)

i don't have the value to save in the record 

Could you hepl me please ? THX



5 Replies

SR Swathi Ravi Syncfusion Team October 16, 2024 02:45 PM UTC

Hi Francesco Pruneri,
Thank you for reaching out to us.
To create a database record using the Blazor Scheduler, you can utilize the URL Adaptor, which allows seamless data binding with your backend. The OnActionCompleted method you mentioned is triggered after actions like CRUD operations, and you can access the appointment details through the args parameter to save them in your database.
To assist you further, we’ve provided a sample that demonstrates how to perform CRUD operations using the URL Adaptor:
Please let us know if you need any additional assistance, and we’ll be happy to help.
Regards,
Swathi


FP Francesco Pruneri October 16, 2024 05:30 PM UTC

I didn't understand, My Code is : 

<SfSchedule TValue="ActivityAppointment"

    Width="100%"

    Height="500px"

    @bind-CurrentView="@CurrentView">

    <ScheduleEvents TValue="ActivityAppointment" EventRendered="OnEventRendered"

        ActionCompleted="OnActionCompleted"

        OnActionBegin="OnActionBegin"

        DataBinding="DataBindHandler"

        >

    </ScheduleEvents>

    <ScheduleEventSettings DataSource="@ActivityAppointmentsDataSource"></ScheduleEventSettings>

    <ScheduleViews>

        <ScheduleView Option="View.Day"></ScheduleView>

        <ScheduleView Option="View.Week"></ScheduleView>

        <ScheduleView Option="View.Month"></ScheduleView>

        <ScheduleView Option="View.Agenda"></ScheduleView>

    </ScheduleViews>

</SfSchedule>


With this method i write the record 

ActivityTicketLookupService.SCreateActivityAppointment(ActivityAppointmentRecord);


in this method i have any Value , no ItemData, no Data. Like DropDown or Combobox or other 


 public void OnActionBegin(Syncfusion.Blazor.Schedule.ActionEventArgs<ActivityAppointment> args)

 {

     args.

 }






SR Swathi Ravi Syncfusion Team October 17, 2024 03:09 PM UTC

Francesco Pruneri,

Thank you for sharing your code. Based on your implementation, it seems like you're looking to retrieve the modified data when performing actions like adding, updating, or deleting events in the Scheduler.

You can access the relevant records in the OnActionBegin method using the following properties:


  1. args.AddedRecords: This contains the data for any newly added events after the save event is triggered.
  2. args.ChangedRecords: This will hold the details of any events that have been modified.
  3. args.DeletedRecords: This property provides the records for any deleted events.

You can utilize these properties within the OnActionBegin method to capture the necessary data for further processing in your ActivityTicketLookupService.SCreateActivityAppointment(ActivityAppointmentRecord) method.

For additional reference, check out the below shared UG link to know more about CRUD actions.

Let us know if you need further clarification or assistance with your implementation. We're here to help!


FP Francesco Pruneri October 17, 2024 04:17 PM UTC

THX For all . I was very close by myself but i missed something ......

Is it right to wirte this code ? 

Is it right to use Last() or it is better to use one other ? 


var Data = args.AddedRecords.Last().StartTime;


In Data i'll have the StartTime ? 




SR Swathi Ravi Syncfusion Team October 18, 2024 01:41 PM UTC

Francesco Pruneri,

 

Yes, your code is correct. Using Last() will retrieve the StartTime from the last record in the AddedRecords collection. As long as you are certain that the AddedRecords collection contains items, Last() will work as expected, and the StartTime will be assigned to Data.


If you have any further questions or need additional assistance, feel free to ask. We're here to help!

Loader.
Up arrow icon