public async Task <JsonResult> Insert()
        {
            try {
                var id         = Guid.NewGuid();
                var rfrom      = Request.Form["RF"];
                var rtID       = Request.Form["RTID"];
                var connID     = Request.Form["CID"];
                var connection = ConnectionServices.GetByID(connID);
                //first check if it is already existing
                var temp = RequestService.GetByConnectionIDRTID(connID, rtID);
                if (temp == null)
                {
                    if (RequestService.Insert(id, rfrom, Guid.Parse(rtID), Guid.Parse(connID), false))
                    {
                        SignalRClients.NotifyInvitationSent(connection.ConnectionName, connection.ID.ToString(), rtID);
                        return(Json(new { success = true }));
                    }
                }
                else if (temp.isArchived)
                {
                    //if it already exist and is archived then unarchive it
                    RequestService.UpdateStatus(false, temp.ID.ToString());

                    SignalRClients.NotifyInvitationSent(connection.ConnectionName, connection.ID.ToString(), rtID);
                    return(Json(new { success = true }));
                }
                return(Json(new { success = false, message = MessageUtility.ServerError() }));
            } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
        }
Exemple #2
0
        public async Task <JsonResult> LeaveConnection()
        {
            try {
                var mid = Request.Form["MID"];
                var uid = Request.Form["UID"];
                var cid = Request.Form["CID"];

                var conn = ConnectionServices.GetByID(cid);
                ConnectionMemberService.UpdateMemberStatus(mid, true);
                //if there no active users in this connection then remove this data from the database
                if (conn.Members.Where(x => x.isArchived == false).Count() <= 0)
                {
                    //remove data from database
                    ConnectionMemberService.RemoveMembersByConnectionID(cid);
                    ConnectionServices.RemoveConnection(cid);
                }
                return(Json(new { success = true }));
            } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); }
        }
Exemple #3
0
 public async Task <JsonResult> GetConnectionMemberUpdatedLocation(string connection)
 {
     try {
         ConnectionViewModel param = json_serializer.Deserialize <ConnectionViewModel>(connection);
         var connectionData        = ConnectionServices.GetByID(param.ID);
         var temp = new ConnectionViewModel()
         {
             ID        = param.ID,
             GroupName = param.GroupName
         };
         foreach (var member in connectionData.Members)
         {
             if (member.isArchived == false)
             {
                 var vm = new UserInformationViewModel()
                 {
                     User = member.UserID.ToString(),
                 };
                 temp.PushMembers(member, vm);
             }
         }
         return(Json(new { success = true, data = temp }, JsonRequestBehavior.AllowGet));
     } catch { return(Json(new { success = false, message = MessageUtility.ServerError() }, JsonRequestBehavior.AllowGet)); }
 }