Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Expand]File Management
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Expand]Pivot Grid
  [Collapse]Scheduler
   [Expand]Overview - SchedulerControl
    Main Features - Scheduler
   [Collapse]Getting Started - Scheduler
     Lesson 1 - Use Scheduler to Display Appointments in Read-Only Mode
     Lesson 2 - Implement Insert-Update-Delete Appointment Functionality
     Lesson 3 - Use Scheduler in Complex Views
     Use Project Template to Create a Fully Functional Application
   [Expand]Concepts - Scheduler
   [Expand]Visual Elements - Scheduler
  [Expand]Tree List
  [Expand]Data Editor Extensions
  [Expand]Report Extensions
  [Expand]SpellChecker
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Lesson 2 - Implement Insert-Update-Delete Appointment Functionality

This step-by-step guide demonstrates how to update a simple application created in the Lesson 1 to enable end-users to add new appointments, modify existing appointments and delete them if necessary.

To enable the appointment editing functionality, do the following.

Expanded Step 1. Add an Action Method

To edit appointments, implement an action method named EditAppointment. It will perform all required modifications, update the scheduler appointment data and pass it to the view for rendering.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3984.

A request for editing can be issued if there is 1) a new appointment to insert 2) one or more appointments with modified properties so they should be updated 3) one or more appointments to delete. To handle all these situations, the UpdateAppointment method calls the SchedulerExtension.GetAppointmentsToInsert<T>, SchedulerExtension.GetAppointmentsToUpdate<T> and the SchedulerExtension.GetAppointmentsToRemove<T> MVC Scheduler extension methods.

Methods GetAppointmentsTo* have several overloads intended for use in different situations. This example utilizes a simple method overload that takes the name of a Scheduler, appointment and resource data and mappings as parameters. The method creates a fake scheduler, applies post data and binds the scheduler to data. Since a SchedulerSettings instance is not passed to the method, there might be some settings that are missed in this case. If these settings affect the number of retrieved appointments, this method overload can produce results different from those expected. To overcome this problem, another method overload is implemented that receives a SchedulerSettings instance. It guarantees correct operation but causes difficulties for the developer.

When appointments are retrieved, the helper methods convert them to data objects and update the data source.

Expanded Step 2. Provide Insert, Update, Delete Methods

The SchedulerDataHelper class is extended with three methods that handle insert, update and delete operations with appointments.

Note that this sample code uses the standard GetHashCode method to assign a unique ID for a newly created appointment. This technique is not generally recommended since the database can provide its own ID via auto incremented field. If this is the case as it is in the CodeCentral example mentioned above, the ID is overwritten after submitting changes via the DataContext.SubmitChanges method. Consider implementing a proper technique to obtain the unique appointment id.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3984.

Expanded Step 3. Modify a View

Now provide a route for the edit appointment action. The code of the Scheduler partial view is shown below.

Expanded Step 4. Observe the Result.

Run the project. You will see the scheduler with editable appointments on a page as illustrated in the following image.

Expanded See Also

How would you rate this topic?​​​​​​​