Пример #1
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            if (Request.Query.TryGetValue("id", out var id_s) &&
                int.TryParse(id_s, out int id))
            {
                var booking = await BookingProvider.GetBookingSummaryById(id);

                Request.Query.TryGetValue("token", out var token);
                if (token != booking.TenantSelfServiceToken)
                {
                    throw new AuthenticationFailedException("Ugyldig eller manglende adgangsnøgle");
                }

                return(View(new BookingCheckoutViewModel
                {
                    BookingId = booking.Id,
                    BookingNumber = booking.BookingNumber,
                    ArrivalDate = booking.ArrivalDate,
                    DepartureDate = booking.DepartureDate,
                    ContactName = booking.ContactName,
                    Deposit = booking.Deposit ?? 0
                }));
            }

            return(View(new BookingCheckoutViewModel()));
        }
Пример #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));
        }
        public async Task <BookingMail> CreateBookingMail(int bookingId, string templateName)
        {
            BookingSummary booking = await BookingProvider.GetBookingSummaryById(bookingId);

            if (booking == null)
            {
                return(null);
            }

            TemplateDataModel template = await TemplateProvider.GetTemplateByName(templateName);

            string message = TemplateProvider.MergeText(template.Text, booking);

            return(new BookingMail
            {
                Description = template.Description,
                To = new MailAddress(booking.ContactEMail, booking.ContactName),
                Subject = template.Subject,
                Message = message
            });
        }