コード例 #1
0
        public IHttpActionResult Comment(string id, [FromBody]Comment comment)
        {
            Comment result;
            if (comment == null || string.IsNullOrWhiteSpace(comment._userId) || string.IsNullOrWhiteSpace(comment.content))
            {
                throw new Exception("Information incompleted");
            }
            using (var reportsService = new ReportsService())
            {
                result = reportsService.Comment(id, comment);
                comment.date = DateTime.UtcNow;
            }

            //Perform push call
            string deviceId = ConfigurationManager.AppSettings.Get("GCMApi");
            if (string.IsNullOrEmpty(deviceId)) { return InternalServerError(new  Exception("No GCMApi configured")); }

            var data = new
            {
                registration_ids = new string[] { "001122334455" },
                data = result
            };
            string response = new PushServiceHelper().SendGCMNotification(deviceId, Newtonsoft.Json.JsonConvert.SerializeObject(data));

            return Ok(result);
        }