コード例 #1
0
        internal static List <FinancedEstate> GetFinancedEstate()
        {
            List <FinancedEstate> estateList = new List <FinancedEstate>();

            #region SharePoint query
            SPListItemCollection queriedEstate = null;

            using (SPSite sps = new SPSite(SPContext.Current.Web.Url))
                using (SPWeb spw = sps.OpenWeb())
                {
                    SPQuery query = new SPQuery();
                    query.Query =
                        "<OrderBy><FieldRef Name='ID' Ascending='FALSE' /></OrderBy>" +
                        "<Where><Eq><FieldRef Name='_ModerationStatus' /><Value Type='ModStat'>0</Value></Eq></Where>";

                    queriedEstate = spw.Lists[LIST_FINANCED_ESTATE].GetItems(query);
                }
            #endregion

            foreach (SPListItem estate in queriedEstate)
            {
                FinancedEstate financedEstate = new FinancedEstate();
                financedEstate.Id          = estate.ID;
                financedEstate.Name        = estate["Nombre_x0020_inmueble"].ToString();
                financedEstate.Code        = estate.Title;
                financedEstate.Type        = estate["Tipo_x0020_bien"].ToString();
                financedEstate.Price       = estate["Precio"] == null ? 0.0 : double.Parse(estate["Precio"].ToString());
                financedEstate.Currency    = estate["Moneda"] == null ? string.Empty : estate["Moneda"].ToString();
                financedEstate.City        = estate["Ciudad"].ToString();
                financedEstate.Zone        = estate["Zona"] == null ? string.Empty : estate["Zona"].ToString();
                financedEstate.Address     = estate["Direcci_x00f3_n"].ToString();
                financedEstate.Description = estate["Descripcion"].ToString();
                financedEstate.Important   = bool.Parse(estate["Destacada"].ToString());
                financedEstate.Offer       = estate["Oferta"] == null ? string.Empty : estate["Oferta"].ToString();
                financedEstate.Builtarea   = estate["Superficie_x0020_construida"] == null ? 0.0 : double.Parse(estate["Superficie_x0020_construida"].ToString());
                financedEstate.Landarea    = estate["Superficie_x0020_terreno"] == null ? 0.0 : double.Parse(estate["Superficie_x0020_terreno"].ToString());
                financedEstate.C_agency    = estate["Agencia_x0020_contacto"].ToString();
                financedEstate.C_name      = estate["Nombre1"].ToString();
                financedEstate.C_phone     = estate["Tel_x00e9_fono"].ToString();
                financedEstate.C_email     = estate["Correo_x0020_electr_x00f3_nico"].ToString();
                financedEstate.Attached    = estate.Attachments.Count == 0 ? string.Empty : estate.Attachments.UrlPrefix + estate.Attachments[0];
                financedEstate.Latlong     = estate["Latitud_x002f_Longitud"] == null ? string.Empty : estate["Latitud_x002f_Longitud"].ToString();

                estateList.Add(financedEstate);
            }

            return(estateList);
        }
コード例 #2
0
        internal static FinancedEstate GetFinancedProperty(int id)
        {
            FinancedEstate financedProperty = null;

            using (SPSite sps = new SPSite(SPContext.Current.Web.Url))
                using (SPWeb spw = sps.OpenWeb())
                {
                    SPListItem item = spw.Lists[LIST_FINANCED_ESTATE].GetItemById(id);

                    if (item != null)
                    {
                        financedProperty = new FinancedEstate();

                        financedProperty.Id          = item.ID;
                        financedProperty.Name        = item["Nombre_x0020_inmueble"].ToString();
                        financedProperty.Code        = item.Title;
                        financedProperty.Type        = item["Tipo_x0020_bien"].ToString();
                        financedProperty.Price       = item["Precio"] == null ? 0.0 : double.Parse(item["Precio"].ToString());
                        financedProperty.Currency    = item["Moneda"] == null ? string.Empty : item["Moneda"].ToString();
                        financedProperty.City        = item["Ciudad"].ToString();
                        financedProperty.Zone        = item["Zona"] == null ? string.Empty : item["Zona"].ToString();
                        financedProperty.Address     = item["Direcci_x00f3_n"].ToString();
                        financedProperty.Description = item["Descripcion"].ToString();
                        financedProperty.Important   = bool.Parse(item["Destacada"].ToString());
                        financedProperty.Offer       = item["Oferta"] == null ? string.Empty : item["Oferta"].ToString();
                        financedProperty.Builtarea   = item["Superficie_x0020_construida"] == null ? 0.0 : double.Parse(item["Superficie_x0020_construida"].ToString());
                        financedProperty.Landarea    = item["Superficie_x0020_terreno"] == null ? 0.0 : double.Parse(item["Superficie_x0020_terreno"].ToString());
                        financedProperty.C_agency    = item["Agencia_x0020_contacto"].ToString();
                        financedProperty.C_name      = item["Nombre1"].ToString();
                        financedProperty.C_phone     = item["Tel_x00e9_fono"].ToString();
                        financedProperty.C_email     = item["Correo_x0020_electr_x00f3_nico"].ToString();
                        financedProperty.Attached    = item.Attachments.Count == 0 ? string.Empty : item.Attachments.UrlPrefix + item.Attachments[0];
                        financedProperty.Latlong     = item["Latitud_x002f_Longitud"] == null ? string.Empty : item["Latitud_x002f_Longitud"].ToString();
                    }
                }

            return(financedProperty);
        }