0

I making app with Angular Syncfusion Scheduler. My backend is .net 6 with OData v8+.

I use for fetch data ODataV4Adapter. Data loading work fine, but if I add new appointment and try validating him on server, Editor windows close a Scheduler don't catch any error of my error on the server.

Scheduler HTML

<ejs-schedule[firstDayOfWeek]="1"[eventSettings]="eventSettings"height="100%"(actionBegin)="actionBegin($event)"(actionFailure)="actionFailure($event)"(actionComplete)="actionComplete($event)"(popupClose)="popupClose($event)">
</ejs-schedule>`
import { Component } from '@angular/core'

import {
    DayService,
    WeekService,
    WorkWeekService,
    MonthService,
    AgendaService,
    TimelineMonthService,
    TimelineViewsService,
    EventSettingsModel,
} from '@syncfusion/ej2-angular-schedule'
import { DataManager, DataResult, ODataV4Adaptor, Query } from '@syncfusion/ej2-data'

@Component({
    selector: 'app-home',
    providers: [DayService, WeekService, WorkWeekService, MonthService, AgendaService, TimelineViewsService, TimelineMonthService],
    templateUrl: './home.component.html',
})
export class HomeComponent {
    private dataManager: DataManager = new DataManager({
        url: '/odata/event',
        adaptor: new ODataV4Adaptor(),
    })

    public eventSettings: EventSettingsModel = {
        dataSource: this.dataManager,
    }

    public allowMultipleOwner: Boolean = true
    public ownerDataSource: Object[] = [{ OwnerText: 'Nancy', Id: 1, OwnerColor: '#ffaa00' }]

    actionFailure(e: Event) { // this error never throw
        console.log('FAIL')
        console.log(e)
    }

    actionComplete(e: Event) {
        console.log('COMPLETE')
        console.log(e)
    }

    actionBegin(e: Event) {
        console.log(e)
    }

    popupClose(e: Event) {
        console.log('POPUP CLOSE')
        console.log(e)
    }
}

Program.cs

var defaultBatchHandler = new DefaultODataBatchHandler();
defaultBatchHandler.MessageQuotas.MaxNestingDepth = 2;
defaultBatchHandler.MessageQuotas.MaxOperationsPerChangeset = 10;
defaultBatchHandler.MessageQuotas.MaxReceivedMessageSize = 100;

builder.Services
    .AddControllers()
    .AddOData(stp =>
        stp.AddRouteComponents("odata", EdmModelBuilder.GetEdmModel(), defaultBatchHandler)
            .Select()
            .OrderBy()
            .Filter()
            .Expand()
            .Count()
            .SetMaxTop(1000)
        )
    .AddJsonOptions(options =>
    {
        options.JsonSerializerOptions.Converters.Add(new DateOnlyJsonConverter());
    }
);

EventController.cs


namespace EC.Scheduler.Controllers;

public class EventController : ODataController
{
    [EnableQuery]
    public IActionResult Get()
    {
        return Ok(new List<Event>() { new Event {
            Id = "aaaaa",
            Subject = "Subject",
            
            StartTime = DateTime.Now,
            EndTime = DateTime.Now.AddHours(3),
            OwnerId = 1
        },
            new Event {
            Id = "bbbbb",
            Subject = "Subject 2",
            Description = "Desc",
            StartTime = DateTime.Now.AddDays(3),
            EndTime = DateTime.Now.AddDays(3).AddHours(4),
            OwnerId = 2
        }
        }.AsQueryable());
    }

    [EnableQuery]
    [HttpPost]
    public IActionResult Post([FromBody] Event e)
    {
        return BadRequest(); // here I return error but scheduler don't catch it
    }

    [EnableQuery]
    [HttpPatch]
    public IActionResult Patch([FromODataUri] string key, Delta<Event> e)
    {
        return Ok();
    }

    [EnableQuery]
    [HttpDelete]
    public async Task<IActionResult> Delete([FromODataUri] string key)
    {
        return Ok();
    }

}

Here is response of my /odata/$batch

{
    "responses": [
        {
            "id": "0",
            "atomicityGroup": "1d4afc3e-023c-4421-9031-8135a2f71d8f",
            "status": 400,
            "headers": {}
        }
    ]
}

If I try add new appointment I expect error not just close add dialog, but nothing happen.

I try catch error on client - ODatav4Adapter, i try catch error on server side, but not success.

I expect if I throw exception or badRequest on server side, appointment is not added and Scheduler throw some exception for validation.

0 Answers0