Beispiel #1
0
        public static TodoItem Update(this TodoItem t, DBRecord record)
        {
            t.ID = record.Id;

            t.Name  = record.GetString("Title");
            t.Notes = record.GetString("Description");
            t.Done  = record.GetBoolean("IsDone");
            return(t);
        }
Beispiel #2
0
        //REGISTRA CONTACTO
        void RegistraContacto(String Nombre, String Telefono)
        {
            //INICIALIZAMOS NUESTRO DATASTORE
            InicializarDropboxDatastore(Account.LinkedAccount);

            //RECUPERAMOS LA TABLA DE NUESTRO DATASTORE PARA REGISTRAR EN ELLA EL NUEVO CONTACTO
            DBTable table = DropboxDatastore.GetTable("Contactos");

            int New_id = 1;
            //RECUPERAMOS TODO LOS CONTACTOS DE LA TABLA
            var results = table.Query();

            //RECUPERAMOS EL ULTIMO ID DEL CONTACTO REGISTRADO Y LO AUMENTAMOS PARA REGISTRA OTRO NUEVO Y NO SE
            //DUPLIQUEN
            if (results.Count() > 0)
            {
                DBRecord UltimoRegistro = results.AsList() [results.Count() - 1];

                New_id = int.Parse(UltimoRegistro.GetString("Id")) + 1;
            }


            //CREAMOS UN OBJECTO DE TIPO CONTACTO
            Contacto cto = new Contacto(New_id.ToString(), Nombre, Telefono);


            //REGISTRAMOS EL OBJECTO CONTACTO PASANDO LA PROPIEDAD DE "Campos" QUE ES DE TIPO DBFields
            table.Insert(cto.Campos());

            //VERIFICAMOS QUE NUESTRA DATASTORE ESTE ABIERTA PARA PODER REALIZAR EL ALTA DEL CONACTO
            if (!EstatusDataStore())
            {
                //REINICIAMOS LA CONEXION CON DROPBOX
                ReiniciarConexion();
            }
            else
            {
                // SI NO HAY NINGUN PROBLEMA DE CONEXION PROCEDEMOS A REALIZAR LA SINCRONIZACION CON NUESTRO DATASTORE
                // Y DAR DE ALTA NUESTRO CONTACTO
                DropboxDatastore.Sync();

                Toast.MakeText(this, "Contacto Registrado", ToastLength.Long).Show();

                txtNombre.Text   = "";
                txtTelefono.Text = "";

                //CERRAMOS LA CONEXION A NUESTRO DATASTORE
                DropboxDatastore.Close();
            }
        }
Beispiel #3
0
        //REGISTRA CONTACTO
        void BuscaContacto(string id)
        {
            InicializarDropboxDatastore(Account.LinkedAccount);

            //RECUPERAMOS LA TABLA DE NUESTRO DATASTORE PARA REGISTRAR EN ELLA EL NUEVO CONTACTO
            DBTable table = DropboxDatastore.GetTable("Contactos");


            //RECUPERA CONTACTO CREANDO UN FILTRO
            var fieldsFiltro = new DBFields();

            fieldsFiltro.Set("Id", id);

            //APLICAMOS EL FILTRO AL QUERY
            var results = table.Query(fieldsFiltro);

            //VERIFICAMOS EL RESULTADO Y SI TIENE RECUPERAMOS EL CONTACTO
            if (results.Count() > 0)
            {
                temp_contacto = results.AsList() [0];

                txtNombre.Text   = temp_contacto.GetString("Nombre");
                txtTelefono.Text = temp_contacto.GetString("Telefono");
            }
            else
            {
                Toast.MakeText(this, "No se encontro el contacto", ToastLength.Long).Show();
            }



            //SINCRONIZAMOS LOS DATOS
            DropboxDatastore.Sync();

            //CERRAMOS LA CONEXION A NUESTRO DATASTORE
            DropboxDatastore.Close();
        }
Beispiel #4
0
        public static Dictionary <string, object> ToDictionary(this DBRecord record, DbMapping mapping)
        {
            var dictionary = new Dictionary <string, object>();

            foreach (var fieldName in record.FieldNames())
            {
                var property = mapping.PropertiesInfos.SingleOrDefault(p => p.Name.Equals(fieldName));
                if (property != null)
                {
                    object value = null;
                    var    type  = property.PropertyType;
                    if (type.IsLong())
                    {
                        value = record.GetLong(fieldName);
                    }
                    else if (type.IsNumeric())
                    {
                        value = record.GetDouble(fieldName);
                    }
                    else if (type.IsBool())
                    {
                        value = record.GetBoolean(fieldName);
                    }
                    else if (type.IsDateTime())
                    {
                        var date = record.GetDate(fieldName);
                        value = date.ToDateTime();
                    }
                    else if (type == typeof(string))
                    {
                        value = record.GetString(fieldName);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                    dictionary.Add(fieldName, value);
                }
            }
            return(dictionary);
        }
		//REGISTRA CONTACTO
		void BuscaContacto (string id)
		{
			InicializarDropboxDatastore (Account.LinkedAccount);

			//RECUPERAMOS LA TABLA DE NUESTRO DATASTORE PARA REGISTRAR EN ELLA EL NUEVO CONTACTO
			DBTable  table = DropboxDatastore.GetTable ("Contactos");


			//RECUPERA CONTACTO CREANDO UN FILTRO 
			var fieldsFiltro = new DBFields();
			fieldsFiltro.Set("Id", id);

			//APLICAMOS EL FILTRO AL QUERY
			var results = table.Query (fieldsFiltro);

			//VERIFICAMOS EL RESULTADO Y SI TIENE RECUPERAMOS EL CONTACTO
			if (results.Count () > 0) {
				temp_contacto = results.AsList () [0];

				txtNombre.Text = temp_contacto.GetString ("Nombre");
				txtTelefono.Text = temp_contacto.GetString ("Telefono");

			} else {
				Toast.MakeText (this, "No se encontro el contacto", ToastLength.Long).Show();
			}



			//SINCRONIZAMOS LOS DATOS
			DropboxDatastore.Sync ();

			//CERRAMOS LA CONEXION A NUESTRO DATASTORE
			DropboxDatastore.Close ();



		}
		public static TodoItem Update (this TodoItem t, DBRecord record)
		{
			t.ID = record.Id;

			t.Name = record.GetString ("Title");
			t.Notes = record.GetString("Description");
			t.Done = record.GetBoolean ("IsDone");
			return t;
		}