Esempio n. 1
0
        public async Task<IHttpActionResult> SignUp([FromBody]Usuario user)
        {
            try
            {
                ParseUser usuario = new ParseUser()
                {
                    Username = user.usuario,
                    Password = user.psw,
                    Email = user.correo
                };
                usuario["nombre"] = user.nombre;
                Byte[] bytes = Convert.FromBase64String(user.foto);
                ParseFile foto = new ParseFile("foto.png", bytes);
                await foto.SaveAsync();
                usuario["foto"] = foto;
                usuario["sexo"] = user.sexo;
                usuario["tipo"] = user.tipo;
                await usuario.SignUpAsync();

                Usuario resp = new Usuario();
                resp.usuario = user.usuario;
                resp.psw = user.psw;
                resp.correo = usuario.Get<string>("email");
                resp.foto = usuario.Get<ParseFile>("foto").Url.AbsoluteUri;
                resp.sexo = usuario.Get<string>("sexo");
                resp.tipo = usuario.Get<string>("tipo");
                resp.nombre = usuario.Get<string>("nombre");
                resp.ObjectId = usuario.ObjectId;
                return Ok(resp);
            }
            catch (ParseException e) {
                return InternalServerError(e);
            }
            
        }
Esempio n. 2
0
        /// <summary>
        /// Save a new location data to the parse user.
        /// This method does not save the data to the server.
        /// Need to call SaveAsync on the user afterwards.
        /// </summary>
        /// <param name="user">the user whose location is to be saved</param>
        /// <param name="newData">the new location data</param>
        public static void SaveLocationToParseUser(ParseUser user, GeoPosition<GeoCoordinate> newData)
        {
            int lastLocationIndex = user.Get<int>(ParseContract.UserTable.LAST_LOCATION_INDEX);
            int newLocationIndex = lastLocationIndex + 1;
            newLocationIndex %= user.Get<int>(ParseContract.UserTable.LOCATION_DATA_SIZE);
            user[ParseContract.UserTable.LAST_LOCATION_INDEX] = newLocationIndex;


            if (!user.ContainsKey(ParseContract.UserTable.LOCATION(newLocationIndex)))//If the new slot was not filled.
            {
                user[ParseContract.UserTable.LOCATION(newLocationIndex)] = ParseContract.LocationTable.GeoPositionToParseObject(newData);
            }
            else//If the new slot contains a valid location
            {
                ParseObject newLocation = user.Get<ParseObject>(ParseContract.UserTable.LOCATION(newLocationIndex));
                //Change the location entry without creating a new one.
                ParseContract.LocationTable.GeoPositionSetParseObject(newData, newLocation);
            }
            user[ParseContract.UserTable.LAST_GEO_POINT] = new ParseGeoPoint(newData.Location.Latitude, newData.Location.Longitude);
        }
 private void enterConversation(ParseUser partner)
 {
     leaveConversation();
     chatUsername.GetComponent<Text>().text = (string)partner[UserValues.NICK];
     StartCoroutine(setUserPicture(partner, partner.Get<ParseFile>(UserValues.PICTURE), chatImage.GetComponent<Image>()));
     //getUserPartners(ParseUser.CurrentUser)
     if (!partnerList.Contains(partner))
     {
         Task saveCurrentUserTask = conversationAdded(ParseUser.CurrentUser, partner);
         StartCoroutine(saveCurrentUserInvokeUpdates(partner, saveCurrentUserTask));
     } else
     {
         this.partner = partner;
     }
     if (userTempEdit.ContainsKey(partner.ObjectId))
         chatField.GetComponent<InputField>().text = userTempEdit[partner.ObjectId];
     else
         chatField.GetComponent<InputField>().text = "";
     foreach(ParseUser user in newMessagesFromPartners)
     {
         if (user.ObjectId.Equals(partner.ObjectId))
         {
             newMessagesFromPartners.Remove(user);
             break;
         }
     }
     ParseUser.CurrentUser[UserValues.NEW_MESSAGE_FROM] = newMessagesFromPartners;
     ParseUser.CurrentUser.SaveAsync();
     removeMarkerNewMessageReceived(partner.ObjectId);
     Debug.Log("enter conversation");
 }
 private static List<ParseUser> getUserList(ParseUser user, string userValue)
 {
     List<ParseUser> partners = null;
     if (user[userValue].GetType() == typeof(List<object>))
         partners = user.Get<List<object>>(userValue).Select(u => (ParseUser)u).ToList();
     else
         partners = user.Get<List<ParseUser>>(userValue).Select(u => (ParseUser)u).ToList();
     return partners;
 }