Exemplo n.º 1
0
        public async Task <IActionResult> GetNotificationOptions()
        {
            var agent = await _agentContextService.GetAgent();

            var slimAgent = new SlimAgentContext(agent.AgentId, agent.AgencyId);

            return(Ok(await _notificationOptionsService.Get(slimAgent)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetNotifications([FromQuery] int skip = 0, [FromQuery] int top = 1000)
        {
            var agent = await _agentContextService.GetAgent();

            var slimAgent = new SlimAgentContext(agent.AgentId, agent.AgencyId);

            return(Ok(await _notificationService.Get(slimAgent, skip, top)));
        }
        public async Task AddAgentNotification(SlimAgentContext agent, JsonDocument message, NotificationTypes notificationType, Dictionary <ProtocolTypes, object> sendingSettings)
        {
            var notification = new Notification
            {
                Receiver        = ReceiverTypes.AgentApp,
                UserId          = agent.AgentId,
                AgencyId        = agent.AgencyId,
                Message         = message,
                Type            = notificationType,
                SendingSettings = sendingSettings
            };

            await SaveAndSend(notification, null);
        }
        public async Task AddAgentNotification(SlimAgentContext agent, DataWithCompanyInfo messageData, NotificationTypes notificationType, Dictionary <ProtocolTypes, object> sendingSettings)
        {
            var notification = new Notification
            {
                Receiver        = ReceiverTypes.AgentApp,
                UserId          = agent.AgentId,
                AgencyId        = agent.AgencyId,
                Message         = JsonDocument.Parse(JsonSerializer.SerializeToUtf8Bytes((object)messageData, new JsonSerializerOptions(JsonSerializerDefaults.Web))),
                Type            = notificationType,
                SendingSettings = sendingSettings
            };

            await SaveAndSend(notification, messageData);
        }
Exemplo n.º 5
0
 public async Task <Result> Send(SlimAgentContext agent, JsonDocument message, NotificationTypes notificationType)
 => await _notificationOptionsService.GetNotificationOptions(agent.AgentId, ApiCallerTypes.Agent, agent.AgencyId, notificationType)
 .Map(notificationOptions => BuildSettings(notificationOptions, null))
 .Tap(sendingSettings => _internalNotificationService.AddAgentNotification(agent, message, notificationType, sendingSettings));
Exemplo n.º 6
0
 public async Task <Result> Send(SlimAgentContext agent, DataWithCompanyInfo messageData, NotificationTypes notificationType, List <string> emails)
 => await _notificationOptionsService.GetNotificationOptions(agent.AgentId, ApiCallerTypes.Agent, agent.AgencyId, notificationType)
 .Map(notificationOptions => BuildSettings(notificationOptions, emails))
 .Tap(sendingSettings => _internalNotificationService.AddAgentNotification(agent, messageData, notificationType, sendingSettings));
Exemplo n.º 7
0
 public async Task <Result> Send(SlimAgentContext agent, DataWithCompanyInfo messageData, NotificationTypes notificationType, string email)
 => await Send(agent, messageData, notificationType, new List <string> {
     email
 });
 public async Task <Result> Update(SlimAgentContext agent, Dictionary <NotificationTypes, NotificationSettings> notificationOptions)
 => await Update(agent.AgentId, ApiCallerTypes.Agent, agent.AgencyId, notificationOptions);
        public async Task <Dictionary <NotificationTypes, NotificationSettings> > Get(SlimAgentContext agent)
        {
            var agentOptions = await _context.NotificationOptions
                               .Where(o => o.AgencyId == agent.AgencyId && o.UserId == agent.AgentId && o.UserType == ApiCallerTypes.Agent)
                               .ToListAsync();

            return(await GetMaterializedOptions(agentOptions, ReceiverTypes.AgentApp));
        }
        public Task <Result> SendVoucher(Booking booking, string email, string languageCode, SlimAgentContext agent)
        {
            return(_documentsService.GenerateVoucher(booking, languageCode)
                   .Bind(async voucher =>
            {
                var voucherData = new VoucherData
                {
                    Accommodation = voucher.Accommodation,
                    AgentName = voucher.AgentName,
                    BookingId = voucher.BookingId,
                    DeadlineDate = DateTimeFormatters.ToDateString(voucher.DeadlineDate),
                    NightCount = voucher.NightCount,
                    ReferenceCode = voucher.ReferenceCode,
                    SupplierReferenceCode = voucher.SupplierReferenceCode,
                    PropertyOwnerConfirmationCode = voucher.PropertyOwnerConfirmationCode,
                    RoomConfirmationCodes = string.Join("; ", voucher.RoomDetails.Select(r => r.SupplierRoomReferenceCode)),
                    RoomDetails = voucher.RoomDetails,
                    CheckInDate = DateTimeFormatters.ToDateString(voucher.CheckInDate),
                    CheckOutDate = DateTimeFormatters.ToDateString(voucher.CheckOutDate),
                    MainPassengerName = voucher.MainPassengerName,
                    BannerUrl = voucher.BannerUrl,
                    LogoUrl = voucher.LogoUrl
                };

                return await _notificationsService.Send(agent: agent,
                                                        messageData: voucherData,
                                                        notificationType: NotificationTypes.BookingVoucher,
                                                        email: email);
            }));
        }
        public Task <Result> SendInvoice(Booking booking, string email, bool sendCopyToAdmins, SlimAgentContext agent)
        {
            // TODO: hardcoded to be removed with UEDA-20
            var addresses = new List <string> {
                email
            };

            if (sendCopyToAdmins)
            {
                addresses.AddRange(_options.CcNotificationAddresses);
            }

            return(_documentsService.GetActualInvoice(booking)
                   .Bind(async invoice =>
            {
                var(registrationInfo, data) = invoice;
                var invoiceData = new InvoiceData
                {
                    Number = registrationInfo.Number,
                    BuyerDetails = data.BuyerDetails,
                    InvoiceDate = DateTimeFormatters.ToDateString(registrationInfo.Date),
                    InvoiceItems = data.InvoiceItems
                                   .Select(i => new InvoiceData.InvoiceItem
                    {
                        Number = i.Number,
                        Price = FormatPrice(i.Price),
                        Total = FormatPrice(i.Total),
                        AccommodationName = i.AccommodationName,
                        RoomDescription = i.RoomDescription,
                        RoomType = EnumFormatters.FromDescription <RoomTypes>(i.RoomType),
                        DeadlineDate = DateTimeFormatters.ToDateString(i.DeadlineDate),
                        MainPassengerName = PersonNameFormatters.ToMaskedName(i.MainPassengerFirstName, i.MainPassengerLastName)
                    })
                                   .ToList(),
                    TotalPrice = FormatPrice(data.TotalPrice),
                    CurrencyCode = EnumFormatters.FromDescription(data.TotalPrice.Currency),
                    ReferenceCode = data.ReferenceCode,
                    SupplierReferenceCode = data.SupplierReferenceCode,
                    SellerDetails = data.SellerDetails,
                    PayDueDate = DateTimeFormatters.ToDateString(data.PayDueDate),
                    CheckInDate = DateTimeFormatters.ToDateString(data.CheckInDate),
                    CheckOutDate = DateTimeFormatters.ToDateString(data.CheckOutDate),
                    PaymentStatus = EnumFormatters.FromDescription(data.PaymentStatus),
                    DeadlineDate = DateTimeFormatters.ToDateString(data.DeadlineDate)
                };

                return await _notificationsService.Send(agent: agent,
                                                        messageData: invoiceData,
                                                        notificationType: NotificationTypes.BookingInvoice,
                                                        emails: addresses);
            }));
        }
Exemplo n.º 12
0
        // TODO: hardcoded to be removed with UEDA-20
        public async Task NotifyBookingFinalized(AccommodationBookingInfo bookingInfo, SlimAgentContext agent)
        {
            await SendDetailedBookingNotification(bookingInfo, bookingInfo.AgentInformation.AgentEmail, agent, NotificationTypes.BookingFinalized);

            await SendDetailedBookingNotification(bookingInfo, NotificationTypes.BookingFinalized);
        }
Exemplo n.º 13
0
        private Task SendDetailedBookingNotification(AccommodationBookingInfo bookingInfo, string recipient, SlimAgentContext agent,
                                                     NotificationTypes notificationType)
        {
            var details          = bookingInfo.BookingDetails;
            var notificationData = CreateNotificationData(bookingInfo, details);

            return(_notificationService.Send(agent: agent,
                                             messageData: notificationData,
                                             notificationType: notificationType,
                                             email: recipient));
        }
Exemplo n.º 14
0
 public Task <List <SlimNotification> > Get(SlimAgentContext agent, int skip, int top)
 => Task.FromResult(new List <SlimNotification>(0));
Exemplo n.º 15
0
 public Task <Result> Send(SlimAgentContext agent, DataWithCompanyInfo messageData, NotificationTypes notificationType, List <string> emails)
 => Task.FromResult(Result.Success());
Exemplo n.º 16
0
 public Task <Result> Send(SlimAgentContext agent, JsonDocument message, NotificationTypes notificationType)
 => Task.FromResult(Result.Success());