Esempio n. 1
0
        public async Task SendAsync(Notification notification, INotificationRepo notificationRepo)
        {
            await TelegramBot._client.SendTextMessageAsync(notification.Receiver, notification.Content);

            var updateModel = new UpdateNotificationDto
            {
                NotificationId = notification.NotificationId,
                Status         = NotificationStatus.Success,
                SendDateMi     = DateTime.Now,
                SendStatus     = "Success",
                IsLock         = true
            };
            await notificationRepo.UpdateAsync(updateModel);
        }
        public async Task <bool> UpdateAsync(UpdateNotificationDto model)
        {
            try
            {
                await _sqlConnection.ExecuteSpCommandAsync <int>("[Notifier].[UpdateNotification]",
                                                                 new { NotificationId = model.NotificationId, Status = model.Status, SendStatus = model.SendStatus, SendDateMi = model.SendDateMi, IsLock = model.IsLock });

                return(true);
            }
            catch (Exception e)
            {
                FileLoger.Error(e);
                return(false);
            }
        }
Esempio n. 3
0
        public async Task SendAsync(Notification notification, INotificationRepo notificationRepo)
        {
            var sendResult = await LinePayamakProvider.SendSmsAsync(notification.Receiver, notification.Content);

            var updateModel = new UpdateNotificationDto
            {
                NotificationId = notification.NotificationId,
                SendDateMi     = DateTime.Now,
                SendStatus     = sendResult
            };

            if (sendResult.Split(':')[1] == "1")
            {
                updateModel.Status = NotificationStatus.Success;
                updateModel.IsLock = true;
            }
            else
            {
                updateModel.Status = NotificationStatus.Failed;
                updateModel.IsLock = false;
            }

            await notificationRepo.UpdateAsync(updateModel);
        }