Ejemplo n.º 1
0
        public IHttpActionResult PostPushNotifications(ChatMessageCreate request)
        {
            bool success1;
            bool success;
            var  deviceToken = UserSecurity.GetDeviceTokenByUserId(AuthHelper.CurrentUser.Id, out success1); //Authentication.GetDeviceTokenBySessionToken(AuthHelper.TokenValue);
            var  platform    = "bbbbb";                                                                      //TODO implement this => Authentication.GetPlatformBySessionToken(AuthHelper.TokenValue);

            PushNotifcationsManager.SendPushNotificationToMobileDevice(deviceToken, request.Message, platform, out success);
            if (success)
            {
                return(Ok("Success"));
            }
            return(Content(HttpStatusCode.BadRequest, "Push notification not sent."));
        }
Ejemplo n.º 2
0
        public IHttpActionResult Post(ChatMessageCreate request)
        {
            // check if receiver is associated with sender, otherwise deny request
            var tpSearchFilter = new AdminCustomerRelationshipFilter
            {
                AdminId    = AuthHelper.CurrentUser.Type == UserSecurity.UserType.Admin ? AuthHelper.CurrentUser.Id : request.ReceiverId,
                CustomerId = AuthHelper.CurrentUser.Type == UserSecurity.UserType.Customer ? AuthHelper.CurrentUser.Id : request.ReceiverId
            };

            if (!true) //TODO implement this => TeachingPlans.FindTeachingPlansAsIQueryable(tpSearchFilter).Any()
            {
                return(Content(HttpStatusCode.Unauthorized, "Permission denied."));
            }

            //TODO create chat message in database
            //var message = new ChatMessageCreate()
            //{
            //    Message = request.Message,
            //    ReceiverID = request.ReceiverId,
            //    SenderID = AuthHelper.CurrentUser.Id,
            //};
            // db.save(message)
            bool   success;
            string deviceToken = UserSecurity.GetDeviceTokenByUserId(request.ReceiverId, out success);

            if (!success)
            {
                return(Content(HttpStatusCode.PreconditionFailed, "AppChatMessageCreated. Push notification not sent."));
            }

            string platform = "bbbbb"; //TODO implement this => Authentication.GetPlatformByDeviceToken(deviceToken);

            if (platform == null)
            {
                return(Content(HttpStatusCode.PreconditionFailed, "AppChatMessageCreated. Push notification not sent."));
            }
            if (CreatePushNotification(request.Message, platform, deviceToken))
            {
                return(Ok("Created. Push notification sent!"));
            }

            return(Content(HttpStatusCode.PreconditionFailed, "AppChatMessageCreated. Push notification not sent."));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Edit a previously sent chat message
 /// </summary>
 public IHttpActionResult Patch(ChatMessageCreate request)
 {
     return(Ok("Updated"));
 }