Ejemplo n.º 1
0
        public static async Task <Bitmap> GetPropertyPhoto(int propertyId)
        {
            Bitmap bitmap = null;

            try
            {
                string          select    = "Id";
                string          filter    = string.Format("sl_propertyIDId eq {0}", propertyId);
                string          orderBy   = "Modified desc";
                List <ListItem> listItems = await ListClient.GetListItems("Property%20Photos", select, string.Empty, 1, filter, orderBy);

                if (listItems != null && listItems.Any())
                {
                    int photoId = Helper.GetInt(listItems[0].mData["Id"]);
                    if (photoId > 0)
                    {
                        string fileServerRelativeUrl = await ListClient.GetFileServerRelativeUrl("Property%20Photos", photoId);

                        if (!string.IsNullOrEmpty(fileServerRelativeUrl))
                        {
                            bitmap = await ListClient.GetFile(fileServerRelativeUrl);
                        }
                    }
                }
            }
            catch (Exception)
            {
                bitmap = null;
            }
            return(bitmap);
        }
Ejemplo n.º 2
0
        public static async Task <Bitmap> GetPhoto(string listName, int photoId)
        {
            Bitmap bitmap = null;

            try
            {
                string fileServerRelativeUrl = await ListClient.GetFileServerRelativeUrl(listName, photoId);

                if (!string.IsNullOrEmpty(fileServerRelativeUrl))
                {
                    bitmap = await ListClient.GetFile(fileServerRelativeUrl);
                }
            }
            catch (Exception)
            {
                bitmap = null;
            }
            return(bitmap);
        }