/// <summary>
        /// Sends the notification asynchronous.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>Task.</returns>
        private async Task SendNotificationAsync(string message)
        {
            try
            {
                Services.Log.Info("Send notification without tag");
                var resultWns = await Services.Push.SendAsync(PushHelper.GetWindowsPushMessageForToastText01(message));

                var json = JsonConvert.SerializeObject(resultWns);
                Debug.WriteLine(json);
                Services.Log.Info(string.Format("Wns-{0}", json));
                var resultGcm = await Services.Push.SendAsync(PushHelper.GetGooglePushMessage(message));

                Services.Log.Info(string.Format("Gcm-{0}", JsonConvert.SerializeObject(resultGcm)));
                var resultMpns = await Services.Push.SendAsync(PushHelper.GetMPNSMessage(message));

                Services.Log.Info(string.Format("Mnps-{0}", JsonConvert.SerializeObject(resultMpns)));
                var resultApns = await Services.Push.SendAsync(PushHelper.GetApplePushMessage(message));

                Services.Log.Info(string.Format("Apns-{0}", JsonConvert.SerializeObject(resultApns)));

                await Services.Push.SendAsync(PushHelper.GetWindowsPushMessageForToastText01(message));

                await Services.Push.SendAsync(PushHelper.GetGooglePushMessage(message));

                await Services.Push.SendAsync(PushHelper.GetMPNSMessage(message));

                await Services.Push.SendAsync(PushHelper.GetApplePushMessage(message));

                Services.Log.Info("Send notification using someTag");
                const string otherMessage = "A second tag was added in AMS.";

                resultWns = await Services.Push.SendAsync(PushHelper.GetWindowsPushMessageForToastText01(otherMessage), NotificationHandler.SomeTag);

                Services.Log.Info(string.Format("Wns-{0}", JsonConvert.SerializeObject(resultWns)));
                resultGcm = await Services.Push.SendAsync(PushHelper.GetGooglePushMessage(otherMessage), NotificationHandler.SomeTag);

                Services.Log.Info(string.Format("Gcm-{0}", JsonConvert.SerializeObject(resultGcm)));
                resultMpns = await Services.Push.SendAsync(PushHelper.GetMPNSMessage(otherMessage), NotificationHandler.SomeTag);

                Services.Log.Info(string.Format("Mnps-{0}", JsonConvert.SerializeObject(resultMpns)));
                resultApns = await Services.Push.SendAsync(PushHelper.GetApplePushMessage(otherMessage), NotificationHandler.SomeTag);

                Services.Log.Info(string.Format("Apns-{0}", JsonConvert.SerializeObject(resultApns)));
            }
            catch (Exception exception)
            {
                Services.Log.Error(exception);
            }
        }
Exemple #2
0
        /// <summary>
        /// The patch special offers schema.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="patch">
        /// The patch.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <SpecialOffersSchema> PatchSpecialOffersSchema(string id, Delta <SpecialOffersSchema> patch)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            if (patch == null)
            {
                throw new ArgumentNullException("patch");
            }
            var dto = await UpdateAsync(id, patch);

            await Services.Push.SendAsync(PushHelper.GetWindowsPushMessageForToastText01("Update:", dto.Title));

            return(dto);
        }
Exemple #3
0
        /// <summary>
        /// The post special offers schema.
        /// </summary>
        /// <param name="item">
        /// The item.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <IHttpActionResult> PostSpecialOffersSchema(SpecialOffersSchema item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (string.IsNullOrEmpty(item.Title) ||
                string.IsNullOrEmpty(item.Subtitle) ||
                string.IsNullOrEmpty(item.Starter1) ||
                string.IsNullOrEmpty(item.Main1) ||
                string.IsNullOrEmpty(item.Dessert1))
            {
                return(BadRequest("There are properties that are not defined."));
            }
            var current = await InsertAsync(item);

            await Services.Push.SendAsync(PushHelper.GetWindowsPushMessageForToastText01("Insert:", current.Title));

            return(CreatedAtRoute("Tables", new { id = current.Id }, current));
        }