- Home
- Forum
- ASP.NET Core
- Disable appointments not created by current user.
Disable appointments not created by current user.
I want to show all the appointments in the schedule but I want to prevent double booking. I want each user to only create or modify their own appointments. Is that possible? I am already using user accounts and each appointment has an owner field.
SIGN IN To post a reply.
2 Replies
LE
Leon
July 11, 2017 04:45 AM UTC
So far I was able to accomplish what I need using the events query-cell-info, appointment-click and drag-start. I just need some ideas on how to prevent double booking.
How do I know if a cell already has an appointment?
Thanks,
KK
Karthigeyan Krishnamurthi
Syncfusion Team
July 12, 2017 07:04 AM UTC
Thank you for contacting Syncfusion support.
We have prepared the sample to prevent the double-booking appointments which can be download from the below location. In the sample, at initial load 1 appointment will be rendered from 10-11 AM at November 18, 2016 and if a user try to create another appointment in the same range (10-11 AM at November 18, 2016) it will be prevented.
<Code>
<ej-schedule id="Schedule1" width="100%" before-appointment-create="OnBeforeAppointmentCreate" height="525px" current-date="new DateTime(2016, 11, 18)">
<e-resources>
<e-resource field="OwnerId" title="Owner" name="Owners" allow-multiple="true">
<e-resource-settings datasource="ViewBag.Owner" text="Text" id="Id" color="Color">
</e-resource-settings>
</e-resource>
</e-resources>
<e-group resources="ViewBag.Group"></e-group>
<e-appointment-settings apply-time-offset="false" id="Id" subject='"Subject"' start-time='"StartTime"' end-time='"EndTime"' all-day='"AllDay"' recurrence='"Recurrence"' recurrence-rule='"RecurrenceRule"' resource-fields='"OwnerId"'>
<e-datamanager id="Data" json="ViewBag.dataSource"></e-datamanager>
</e-appointment-settings>
</ej-schedule>
<script>
function OnBeforeAppointmentCreate(args) {
var schObj = $("#Schedule1").ejSchedule('instance');
if (ej.isNullOrUndefined(args.appointment[0]))
obj = args.appointment;
else
obj = args.appointment[0];
var predicate = ej.Predicate(schObj._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, new Date(obj.StartTime)).and(schObj._appointmentSettings["endTime"], ej.FilterOperators.greaterThanOrEqual, new Date(new Date(obj.EndTime)));
var newAppList = new ej.DataManager(schObj._processed).executeLocal(new ej.Query().where(predicate));
if (newAppList.length > 0)
args.cancel = true;
}
</script>
</Code>
Note: Above code will prevent the double booking occurring only at the same range.
Regards,
Karthigeyan
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
LE Leon
- Jul 10, 2017 05:44 AM UTC
- Jul 12, 2017 07:04 AM UTC