コード例 #1
0
        public async Task <JsonResult> Get([FromQuery] DateTime start, [FromQuery] DateTime end)
        {
            var bookings = await BookingService.FindBookingsInInterval(new SearchBookingSummariesQuery
            {
                Start       = start,
                End         = end,
                IsCancelled = false
            });

            var expandedBookingDays = bookings.SelectMany(b => b.ExpandDays());

            IExecutionContext executionContext = await ExecutionContextFactory.CreateAsync();

            bool hasEditAccess = PermissionValidationService.HasCustomEntityPermission <CustomEntityUpdatePermission>(BookingCustomEntityDefinition.DefinitionCode, executionContext.UserContext);

            var events = expandedBookingDays.Select(b => new CalendarEvent
            {
                start       = b.Date,
                title       = "Optaget",
                description = hasEditAccess ? $"#{b.Booking.BookingNumber} - {b.Booking.Purpose}" : null,
                booking_id  = hasEditAccess ? b.Booking.Id : (int?)null
            });

            return(new JsonResult(events));
        }
コード例 #2
0
        public async Task <JsonResult> Get([FromQuery] int id)
        {
            IExecutionContext executionContext = await ExecutionContextFactory.CreateAsync();

            PermissionValidationService.EnforceCustomEntityPermission <CustomEntityReadPermission>(BookingCustomEntityDefinition.DefinitionCode, executionContext.UserContext);

            BookingSummary booking = await BookingProvider.GetBookingSummaryById(id);

            return(ApiResponseHelper.SimpleQueryResponse(booking));
        }
コード例 #3
0
        private async Task <IExecutionContext> CreateExecutionContextAsync(IExecutionContext cx)
        {
            if (cx == null)
            {
                return(await _executionContextFactory.CreateAsync());
            }

            if (cx.UserContext == null)
            {
                throw new ExecutionContextNotInitializedException("The UserContext property cannot be null");
            }

            if (cx.ExecutionDate == DateTime.MinValue)
            {
                throw new ExecutionContextNotInitializedException("The ExecutionDate property has not been set");
            }

            return(cx);
        }