We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Bind Schedule Appointment to Model class

Hi,

I have a Model class Work like this:

    public class Work
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int WorkId { get; set; }

        public string WorkCode { get; set; }

        public DateTime? WorkPlanningDate { get; set; }

        public DateTime? WorkStartPlanningDate { get; set; }

        public DateTime? WorkEndPlanningDate { get; set; }

        public int WorkYear { get; set; }

        public int WorkMonth { get; set; }

        public string WorkDescription { get; set; }

        [ScriptIgnore]
        public virtual ICollection<WorkOperator> WorkOperators { get; set; }
    }

    public class WorkOperator
    {
        public int WorkOperatorId { get; set; }

        public int WorkId { get; set; }
        public virtual Work Work { get; set; }

        public int OperatorId { get; set; }
        public virtual Operator Operator { get; set; }
    }

Is it possible to bind Schedule appointments so that the list of WorkOperator objects are considered as multiple resources?

Something like this:

    @(Html.EJ().Schedule("WorkSchedule")
          .Width("100%")
          .Height("800px")
          .Views(view)
          .Orientation(Orientation.Horizontal)
          .ShowCurrentTimeIndicator(true)
          .CategorizeSettings(fields => fields.Datasource(ViewBag.categorize).Enable(true).AllowMultiple(false).Id("id").Text("text").Color("color").FontColor("fontColor"))
          .DateFormat("dd/MM/yyyy")
          .AllowDragDrop(true)
          .CurrentDate(System.DateTime.Now)
          .Resources(res =>
          {
              res.Field("OperatorId").Title("Operator").Name("Operators").AllowMultiple(true)
              .ResourceSettings(flds => flds.Datasource((IEnumerable<WorkOperator>)Model.WorkOperators).Text("text").Id("id").GroupId("groupId").Color("color")).Add();
          })
          .Group(gr =>
          {
              gr.Resources(ViewBag.Resources);
          })
          .AppointmentSettings(fields => fields.Datasource(ds => ds.Json((IEnumerable<Work>)Model).Adaptor(AdaptorType.UrlAdaptor))
        .Id("WorkId")
        .Subject("WorkCode")
        .StartTime("WorkStartPlanningDate")
        .EndTime("WorkEndPlanningDate")
        .Description("WorkCode")
        .AllDay("False")
        .Recurrence("")
        .RecurrenceRule("")
        .Categorize("Categorize")
        //.Categorize("Categorize")
        .ResourceFields("OperatorId")
        )
        .AppointmentTemplateId("#WorkTemplate")
        .ScheduleClientSideEvents(evt =>
        evt.Create("onCreate")
        .CellClick("onCellClick")
        .AppointmentClick("onAppointmentClick")
        .AppointmentSaved("onAppointmentSaved")
        .AppointmentEdited("onAppointmentEdited")
        .ResizeStop("onResizeStop")
        .ActionComplete("onActionComplete")
        .DragStop("onDragStop")
        ))

Thanks in advance.

Loader.
Up arrow icon