示例#1
0
        /// <summary>
        /// 通知使用者
        /// </summary>
        /// <param name="requestDTO"></param>
        /// <returns></returns>
        public async Task <NotifyResponseDTO> Notify(NotifyRequestDTO requestDTO)
        {
            var query = new Dictionary <string, string>();

            query.Add("message", Environment.NewLine + Environment.NewLine + requestDTO.Message);

            var result = await executeApi <NotifyResponseDTO>(HttpMethod.Post, _setting.NotifyApi, requestDTO.AccessToken, query);

            return(result);
        }
示例#2
0
        public async Task <ActionResult <string> > SendNotificationInterests(NotifyRequestDTO notifyRequest)
        {
            var sender = await _userRepository.GetUserById(notifyRequest.SenderId);

            var receivers = new List <User>();

            foreach (var receiverId in notifyRequest.ReceiverIds)
            {
                receivers.Add(await _userRepository.GetUserById(receiverId));
            }

            try
            {
                await _notificationService.SendShowInterestsNotification(sender, receivers, notifyRequest.Title, notifyRequest.Body);
            }
            catch
            {
                return(BadRequest("Notification failed"));
            }

            return(Ok("Notification send"));
        }