public async Task <JsonResult> GetByParticipantID(string id, string api)
 {
     try {
         var data = MessagingRoomParticipantService.GetByParticipantID(id, Guid.Parse(api));
         return(Success(MessagingRoomParticipantsVM.MsToVMs(data)));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
        public async Task <JsonResult> Insert()
        {
            try {
                var id    = Guid.NewGuid();
                var text  = Request.Form["text"];
                var mtype = Guid.Parse(Request.Form["mtype"]);
                var sid   = Request.Form["sid"];
                var rid   = Guid.Parse(Request.Form["rid"]);
                var api   = Guid.Parse(Request.Form["api"]);
                if (MessagingConversationService.Insert(id, text, mtype, sid, rid, DateTime.Now))
                {
                    //add notification to users that this user sent a message
                    //do not include the uid that sent the message
                    var receipents = MessagingRoomParticipantService.GetByRoomIDExceptUID(rid, sid);
                    var nid        = Guid.NewGuid();
                    NotificationService.Insert(nid, text, api, "New Message");
                    foreach (var r in receipents)
                    {
                        var nrID = Guid.NewGuid();
                        NotificationService.InsertNR(nrID, nid, r.UserID, api);
                        //invoke signal r that there is a new message notification for the users
                        //nrID=id for notificationReceipent so that if its confirmed received this id will be passed back to the
                        //server to remove the notificationreceipent

                        var textToSend = this.IdentifyMessageNotification(mtype.ToString(), text);
                        NotificationManagerHub.SendNotification(nrID.ToString(), api.ToString(), r.UserID, "New Message", textToSend);
                        MessagingAppHub.SendNotification(id.ToString(), api.ToString(), rid.ToString());
                    }
                    return(Success(id.ToString()));
                }
                return(Failed(MessageUtility.ServerError()));
            } catch { return(Failed(MessageUtility.ServerError())); }
        }
 public async Task <JsonResult> Remove()
 {
     try {
         var id = Guid.Parse(Request.Form["id"]);
         if (MessagingRoomParticipantService.Remove(id))
         {
             return(Success(""));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> Insert()
 {
     try {
         var id     = Guid.NewGuid();
         var uid    = Request.Form["uid"];
         var roomID = Guid.Parse(Request.Form["rid"]);
         var api    = Guid.Parse(Request.Form["api"]);
         if (MessagingRoomParticipantService.Insert(id, uid, roomID, api))
         {
             return(Success(id.ToString()));
         }
         else
         {
             return(Failed(MessageUtility.ServerError()));
         }
     } catch { return(Failed(MessageUtility.ServerError())); }
 }