а

Update on Server Side Integration.


#1

Hi all,
I’m using the scheduler in a day with with events assigned to multiple of them.
When I reschedule and event (with drag and drop) I dont’ receive the units lists as parameters of the callback:

Here the demo for JS and HTML: docs.dhtmlx.com/scheduler/snippet/6a24cd1f

On the server this is the method. The changedEvent.unit = null;

[HttpPost]
public ContentResult Save(int? id, FormCollection actionValues)
{
var action = new DataAction(actionValues);

        try
        {
            var changedEvent = (AreaBackend.Models.PlanningAppuntamentoItem)DHXEventsHelper.Bind(typeof(AreaBackend.Models.PlanningAppuntamentoItem), actionValues);
            DateTime inizio;
            if (!DateTime.TryParse(changedEvent.start_date, out inizio)) throw new Exception("Data Inizio non valida.");

            DateTime fine;
            if (!DateTime.TryParse(changedEvent.end_date, out fine)) throw new Exception("Data Fine non valida.");


            switch (action.Type)
            {
                case DataActionTypes.Insert:
                    //do insert
                    // action.TargetId = changedEvent.id;//assign postoperational id
                    break;
                case DataActionTypes.Delete:
                    //do delete
                    break;
                default:// "update"                          
                    //do update
                    var appuntamento = AppSession.Abo.Appuntamenti.GetById(changedEvent.id_appuntamento);
                    appuntamento.Inizio = inizio;
                    appuntamento.Fine = fine;
                    //var ris = appuntamento.AppuntamentiRisorse.FirstOrDefault
                    AppSession.Abo.Appuntamenti.Save(appuntamento, null, true);
                    break;
            }
        }
        catch (Exception e)
        {
            action.Type = DataActionTypes.Error;
            throw e;
        }
        //return (ContentResult)new AjaxSaveResponse(action);
        return Content("Ok");
    }

Could you please check what I’m doing wrong ?

Thanks,
Fabio


#2

After a lot of work I realized the server receive the unit list in the FormCollection :

id=28&text=SAMBO%20CECILIA%20-%20MASSAGGIO%20RELAX&start_date=01-02-2018%2008%3A25&end_date=01-02-2018%2009%3A25&unit=3%2C12&id_appuntamento=2aef10f2-9c5e-4aa4-9209-8cf9013961d3&!nativeeditor_status=updated

but DHXEventsHelper.Bind() is not able to bind it to my class:

public class PlanningAppuntamentoItem
{
public string id { get; set; }
public string text { get; set; }
public string start_date { get; set; }
public string end_date { get; set; }
//public string id_risorsa { get; set; }
public List unit { get; set; }
public string id_appuntamento { get; set; }
}

Please note that I have tried to declare unit as List too but nothing changes.

Thanks,
Fabio