示例#1
0
        public async Task <ActionResult> send_message()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <JGN_Messages_Recipents>(json);

            var _message = await MessageBLL.sendMessage(_context, data);

            // receiver message info
            var info = await SiteConfig.userManager.FindByIdAsync(data.to_uid);

            if (info != null)
            {
                // await _emailSender.SendMessage(_context, model.ContactEmail, model);
            }

            // generate and push notification
            var notif = new JGN_Notifications()
            {
                sender_id         = data.message.from_uid,
                notification_type = (byte)NotificationTypes.Message,
                title             = "New Message Received",
                body         = data.message.subject,
                href         = Config.GetUrl(SystemDirectoryPaths.MessageUrl),
                recipient_id = data.to_uid
            };
            await NotificationBLL.postNotification(_context, notif);

            return(Ok(new { status = "success", message = "Message Sent", record = _message }));
        }