コード例 #1
0
        public async Task Attachment_GetAll_CanDeserializeResponse()
        {
            RestClient.RespondWith(r =>
            {
                return(new Attachments
                {
                    Attachment =
                    {
                        new Attachment {
                            Id = 4711
                        },
                        new Attachment {
                            Id = 4712
                        },
                    }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            var a = (await re.Attachments.GetAsync()).ToList();

            Assert.Equal(2, a.Count);
            Assert.Equal(4711, a[0].Id);
            Assert.Equal(4712, a[1].Id);
        }
        /// <summary>
        /// Copy one item item to another for the uses of content lifecycle management
        /// </summary>
        /// <param name="source">Item to copy from</param>
        /// <param name="destination">Item to copy to</param>
        public void Copy(RealEstateItem source, RealEstateItem destination)
        {
            //this.Provider.CopyContent(source, destination);
            destination.Urls.ClearDestinationUrls(source.Urls, this.Delete);
            source.Urls.CopyTo(destination.Urls, destination);
            ////Not going through the Content property as it has logic that strips all localizable values of the Lstring.
            //destination.GetString("Content").CopyFrom(source.GetString("Content"));
            //// that's how we copy lstring-s
            //destination.GetString("WhatIsInTheBox").CopyFrom(source.GetString("WhatIsInTheBox"));

            destination.ItemNumber       = source.ItemNumber;
            destination.Address          = source.Address;
            destination.PostalCode       = source.PostalCode;
            destination.Housing          = source.Housing;
            destination.NumberOfRooms    = source.NumberOfRooms;
            destination.NumberOfFloors   = source.NumberOfFloors;
            destination.YearBuilt        = source.YearBuilt;
            destination.Price            = source.Price;
            destination.Payment          = source.Payment;
            destination.MonthlyRate      = source.MonthlyRate;
            destination.Net              = source.Net;
            destination.PriceSquareMeter = source.PriceSquareMeter;
            destination.Latitude         = source.Latitude;
            destination.Longitude        = source.Longitude;
            destination.AgentId          = source.AgentId;
        }
コード例 #3
0
        private void ItemsListControl_ItemDataBound(object sender, RadListViewItemEventArgs e)
        {
            if (e.Item.ItemType != RadListViewItemType.DataItem && e.Item.ItemType != RadListViewItemType.AlternatingItem)
            {
                return;
            }

            RealEstateItem item = ((RadListViewDataItem)e.Item).DataItem as RealEstateItem;

            if (item == null)
            {
                return;
            }

            System.Web.UI.WebControls.Image photo = (System.Web.UI.WebControls.Image)e.Item.FindControl("Photo");

            if (isThumbView)
            {
                photo.ImageUrl = item.GetPhotoUrl(SinglePhotoType.ThumbnailListPhoto);
            }
            else
            {
                photo.ImageUrl = item.GetPhotoUrl(SinglePhotoType.FlowListPhoto);
            }

            RadListView FeaturesList = (RadListView)e.Item.FindControl("FeaturesList");

            FeaturesList.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(FeaturesList_ItemDataBound);
            FeaturesList.DataSource     = item.GetTaxons <FlatTaxon>(TaxonType.Features);
            FeaturesList.DataBind();
        }
コード例 #4
0
        public async Task Attachment_CreateVideo_HasFile()
        {
            var bytes = File.ReadAllBytes(@"..\..\..\test.avi");

            RestClient.RespondWith(r =>
            {
                return(new VideoUploadTicket {
                    Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz"
                });
            }).ThenWith(r =>
            {
                var file = r.Files.Single(f => f.Name == "videofile");
                Assert.Equal("application/octet-stream", file.ContentType);
                Assert.Equal("test.avi", file.FileName);
                Assert.Equal(bytes.Length, file.ContentLength);
                var ms = new MemoryStream();
                file.Writer(ms);
                AssertEx.CollectionEqual(bytes, ms.ToArray());
                return("ok");
            }).ThenWith(r =>
            {
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711"
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(new StreamingVideo { Title = "Video" }, @"..\..\..\test.avi");
        }
コード例 #5
0
        public async Task Attachment_CreateVideo_ErrorOccursAtPostAttachment_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new VideoUploadTicket {
                    Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz"
                });
            }).ThenWith(r =>
            {
                return("ok");
            }).ThenWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var video = new StreamingVideo {
                    Title = "Video"
                };
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\..\test.avi");
            });
        }
        private RealEstateItem ResolveDetailItemFromUrl()
        {
            RealEstateItem result  = null;
            var            itemUrl = this.GetUrlParameterString(true);

            if (itemUrl != null)
            {
                string redirectUrl;
                string urlKeyPrefix = String.Empty;
                var    item         = (IContent)this.RealEstateManager.GetItemFromUrl(typeof(RealEstateItem), itemUrl, true, out redirectUrl);
                if (item != null)
                {
                    if (!String.IsNullOrEmpty(this.GetUrlParameterString(false)))
                    {
                        var matches = Regex.Matches(this.GetUrlParameterString(false), widgetNameRegularExpression);
                        if ((matches.Count == 1 && matches[0].Groups["urlPrefix"].Value == urlKeyPrefix) ||
                            (matches.Count == 0 && String.IsNullOrEmpty(urlKeyPrefix)))
                        {
                            result = (RealEstateItem)item;
                        }
                    }
                }
            }

            return(result);
        }
コード例 #7
0
        public async Task Attachment_Create_HasMetadata()
        {
            RestClient.RespondWith(r =>
            {
                var meta = r.Files.Single(f => f.Name == "metadata");
                Assert.Equal("application/xml", meta.ContentType);
                Assert.Equal("body.xml", meta.FileName);
                var ms = new MemoryStream();
                meta.Writer(ms);
                var bytes = ms.ToArray();
                Assert.Equal(bytes.Length, meta.ContentLength);
                var content = Encoding.UTF8.GetString(bytes);
                var a       = new BaseXmlDeserializer().Deserialize <Attachment>(new RestResponse {
                    Content = content
                });
                Assert.IsType <Picture>(a);
                Assert.Equal("Test", a.Title);

                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711"
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.CreateAsync(new Picture { Title = "Test" }, @"..\..\..\test.jpg");
        }
コード例 #8
0
        public async Task Attachment_Create_HasFile()
        {
            var bytes = File.ReadAllBytes(@"..\..\..\test.jpg");

            RestClient.RespondWith(r =>
            {
                var file = r.Files.Single(f => f.Name == "attachment");
                Assert.Equal("image/jpeg", file.ContentType);
                Assert.Equal("test.jpg", file.FileName);
                Assert.Equal(bytes.Length, file.ContentLength);
                var ms = new MemoryStream();
                file.Writer(ms);
                AssertEx.CollectionEqual(bytes, ms.ToArray());
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711"
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.CreateAsync(new Picture { Title = "Test" }, @"..\..\..\test.jpg");
        }
コード例 #9
0
        public async Task Attachment_CreateVideo_CanDeserializeResponse()
        {
            RestClient.RespondWith(r =>
            {
                return(new VideoUploadTicket {
                    Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz"
                });
            }).ThenWith(r =>
            {
                return("ok");
            }).ThenWith(r =>
            {
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711"
                                } }
                });
            });

            var video = new StreamingVideo {
                Title = "Video"
            };
            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\..\test.avi");

            Assert.Equal(4711, video.Id);
            Assert.Equal("xyz", video.VideoId);
        }
        private void ItemsList_ItemDataBound(object sender, RadListViewItemEventArgs e)
        {
            if (e.Item.ItemType != RadListViewItemType.DataItem && e.Item.ItemType != RadListViewItemType.AlternatingItem)
            {
                return;
            }

            RadListViewDataItem dataItem = (RadListViewDataItem)e.Item;
            RealEstateItem      item     = (RealEstateItem)dataItem.DataItem;

            string sliderThumbnailUrl = item.GetPhotoUrl(SinglePhotoType.SliderThumbnail);

            if (sliderThumbnailUrl.IsNullOrEmpty())
            {
                e.Item.Visible = false;
                return;
            }

            HyperLink hlPhoto = (HyperLink)e.Item.FindControl("hlPhoto");

            hlPhoto.NavigateUrl = this.CurrentPageUrl + this.RealEstateManager.GetItemUrl(item);

            HyperLink hlDetails = (HyperLink)e.Item.FindControl("hlDetails");

            hlDetails.NavigateUrl = hlPhoto.NavigateUrl;
            hlDetails.Text        = item.Title;

            Image imgThumbnail = (Image)e.Item.FindControl("imgThumbnail");

            imgThumbnail.AlternateText = item.Title;
            imgThumbnail.ImageUrl      = sliderThumbnailUrl;
        }
コード例 #11
0
        public static bool IsForSale(this RealEstateItem realEstateItem)
        {
            bool result = false;

            if ((realEstateItem.GetValue <TrackedList <Guid> >("Category")).Contains(RealEstateModule.ForSaleItemTypeTaxonId))
            {
                result = true;
            }

            return(result);
        }
コード例 #12
0
        public static T GetTaxon <T>(this RealEstateItem realEstateItem, TaxonType taxonType) where T : Taxon
        {
            var ids = (TrackedList <Guid>)realEstateItem.GetValue(taxonType.ToString());

            if (ids != null && ids.Count > 0)
            {
                return(taxonomyManager.GetTaxon <T>(ids[0]));
            }

            return(null);
        }
        public static List <Photo> GetPhotos(this RealEstateItem realEstateItem, MultiplePhotoType photoType)
        {
            List <Photo> photos = null;

            var itemAlbum = App.Prepare().WorkWith().Albums()
                            .Where(album => album.Title.Equals(realEstateItem.ItemNumber, StringComparison.OrdinalIgnoreCase))
                            .Get().FirstOrDefault();

            if (itemAlbum != null)
            {
                var allPhotos = itemAlbum.Images()
                                .Where(i => i.Status == Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);

                Guid tagId = Guid.Empty;

                if (photoType == MultiplePhotoType.OverviewTabPhoto)
                {
                    tagId = RealEstateModule.OverviewTabPhotoTaxonId;
                }
                else if (photoType == MultiplePhotoType.PhotosTabPhoto)
                {
                    tagId = RealEstateModule.PhotosTabPhotoTaxonId;
                }
                else if (photoType == MultiplePhotoType.PanaromicViewTabPhoto)
                {
                    tagId = RealEstateModule.PanaromicViewTabPhotoTaxonId;
                }
                else if (photoType == MultiplePhotoType.FloorPlanTabPhoto)
                {
                    tagId = RealEstateModule.FloorPlanTabPhotoTaxonId;
                }

                if (!tagId.Equals(Guid.Empty))
                {
                    photos = (
                        from p in allPhotos.Where(p => (p.GetValue <TrackedList <Guid> >("Category")).Contains(tagId))
                        select new Photo
                    {
                        Id = p.Id,
                        Title = p.Title,
                        Description = p.Description,
                        Url = string.Format("{0}{1}", librariesManager.GetItemUrl(p), p.Extension)
                    }
                        )
                             .ToList();
                }
                else
                {
                    // initialize to an empty list of photos
                    photos = new List <Photo>(0);
                }
            }
            return(photos);
        }
コード例 #14
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Get_RequestsCorrectResource()
        {
            Http.RespondWith(m =>
            {
                Assert.Equal("GET", m);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment/1", Http.Url.ToString());
                return new Picture { Id = 1 };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            var a = await re.Attachments.GetAsync("1");
        }
コード例 #15
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Update_RequestsCorrectResource()
        {
            Http.RespondWith(m =>
            {
                Assert.Equal("PUT", m);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment/1", Http.Url.AbsoluteUri);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.UpdateAsync(new Picture { Id = 1 });
        }
コード例 #16
0
        public static List <T> GetTaxons <T>(this RealEstateItem realEstateItem, TaxonType taxonType) where T : Taxon
        {
            List <T> result = new List <T>();
            var      ids    = (TrackedList <Guid>)realEstateItem.GetValue(taxonType.ToString());

            foreach (var id in ids)
            {
                result.Add(taxonomyManager.GetTaxon <T>(id));
            }

            return(result);
        }
コード例 #17
0
        public static string GetPhotoUrl(this RealEstateItem realEstateItem, SinglePhotoType photoType)
        {
            string url = string.Empty;

            var itemAlbum = App.Prepare().WorkWith().Albums()
                            .Where(album => album.Title.Equals(realEstateItem.ItemNumber, StringComparison.OrdinalIgnoreCase))
                            .Get().FirstOrDefault();

            if (itemAlbum != null)
            {
                var allPhotos = itemAlbum.Images()
                                .Where(i => i.Status == Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);

                Guid tagId = Guid.Empty;

                if (photoType == SinglePhotoType.SliderPhoto)
                {
                    tagId = RealEstateModule.SliderPhotoTaxonId;
                }
                else if (photoType == SinglePhotoType.SliderThumbnail)
                {
                    tagId = RealEstateModule.SliderThumbnailTaxonId;
                }
                else if (photoType == SinglePhotoType.FlowListPhoto)
                {
                    tagId = RealEstateModule.FlowListPhotoTaxonId;
                }
                else if (photoType == SinglePhotoType.ThumbnailListPhoto)
                {
                    tagId = RealEstateModule.ThumbnailListPhotoTaxonId;
                }
                else if (photoType == SinglePhotoType.SimilarPropertiesPhoto)
                {
                    tagId = RealEstateModule.SimilarPropertiesPhotoTaxonId;
                }

                if (!tagId.Equals(Guid.Empty))
                {
                    var photo = allPhotos
                                .Where(p => (p.GetValue <TrackedList <Guid> >("Category")).Contains(tagId))
                                .Take(1)
                                .FirstOrDefault();

                    if (photo != null)
                    {
                        url = string.Format("{0}{1}", librariesManager.GetItemUrl(photo), photo.Extension);
                    }
                }
            }

            return(url);
        }
コード例 #18
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Get_ResourceDoesNotExist_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.NotFound, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var re = new RealEstateItem(new ApartmentRent { Id = 1 }, Client.Connection);
                var a = await re.Attachments.GetAsync("x");
            });
        }
コード例 #19
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Get_CanDeserializeResponse()
        {
            Http.RespondWith(m =>
            {
                return new Picture { Id = 1 };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 1 }, Client.Connection);
            var a = await re.Attachments.GetAsync("1");

            Assert.IsType<Picture>(a);
            Assert.Equal(1, a.Id);
        }
コード例 #20
0
        public async Task Attachment_Update_CallSucceeds_NoExceptionThrown()
        {
            RestClient.RespondWith(r =>
            {
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = ""
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.UpdateAsync(new Picture { Id = 1 });
        }
コード例 #21
0
        public async Task AttachmentsOrder_Get_RequestsCorrectResource()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.GET, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment/attachmentsorder", RestClient.BuildUri(r).ToString());
                return(new AttachmentsOrder.List {
                    AttachmentId = { 1, 2, 3 }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            var list = await re.Attachments.AttachmentsOrder.GetAsync();
        }
コード例 #22
0
        public async Task Attachment_CreateLink_CallSucceeds_NoExceptionThrown()
        {
            RestClient.RespondWith(r =>
            {
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711"
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.CreateAsync(new Link { Url = "http://www.example.com" });
        }
コード例 #23
0
        public async Task Attachment_GetAll_RequestsCorrectResource()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.GET, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment", RestClient.BuildUri(r).AbsoluteUri);
                return(new Attachments {
                    Attachment = { }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            var a = await re.Attachments.GetAsync();
        }
コード例 #24
0
        public async Task AttachmentsOrder_Get_CanDeserializeResponse()
        {
            RestClient.RespondWith(r =>
            {
                return(new AttachmentsOrder.List {
                    AttachmentId = { 1, 2, 3 }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 1
            }, Client.Connection);
            var list = await re.Attachments.AttachmentsOrder.GetAsync();

            Assert.IsType <AttachmentsOrder.List>(list);
            AssertEx.CollectionEqual <long>(new long[] { 1, 2, 3 }, list.AttachmentId);
        }
コード例 #25
0
        public async Task Attachment_Get_ResourceDoesNotExist_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.NotFound, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 1
                }, Client.Connection);
                var a = await re.Attachments.GetAsync("x");
            });
        }
コード例 #26
0
        public async Task Attachment_Get_CanDeserializeResponse()
        {
            RestClient.RespondWith(r =>
            {
                return(new Picture {
                    Id = 1
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 1
            }, Client.Connection);
            var a = await re.Attachments.GetAsync("1");

            Assert.IsType <Picture>(a);
            Assert.Equal(1, a.Id);
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RealEstateItemViewModel"/> class.
 /// </summary>
 /// <param name="contentItem">The content item.</param>
 /// <param name="provider">The provider.</param>
 public RealEstateItemViewModel(RealEstateItem contentItem, ContentDataProviderBase provider)
     : base(contentItem, provider)
 {
     this.itemNumber       = contentItem.ItemNumber;
     this.address          = contentItem.Address;
     this.postalCode       = contentItem.PostalCode;
     this.housing          = contentItem.Housing;
     this.numberOfRooms    = contentItem.NumberOfRooms;
     this.numberOfFloors   = contentItem.NumberOfFloors;
     this.yearBuilt        = contentItem.YearBuilt;
     this.price            = contentItem.Price;
     this.payment          = contentItem.Payment;
     this.monthlyRate      = contentItem.MonthlyRate;
     this.net              = contentItem.Net;
     this.priceSquareMeter = contentItem.PriceSquareMeter;
     this.agentId          = contentItem.AgentId;
 }
コード例 #28
0
        private void SlidesList_ItemDataBound(object sender, RadListViewItemEventArgs e)
        {
            if (e.Item.ItemType != RadListViewItemType.DataItem && e.Item.ItemType != RadListViewItemType.AlternatingItem)
            {
                return;
            }

            RadListViewDataItem dataItem = (RadListViewDataItem)e.Item;
            RealEstateItem      item     = (RealEstateItem)dataItem.DataItem;

            string sliderPhotoUrl     = item.GetPhotoUrl(SinglePhotoType.SliderPhoto);
            string sliderThumbnailUrl = item.GetPhotoUrl(SinglePhotoType.SliderThumbnail);

            if (sliderPhotoUrl.IsNullOrEmpty() || sliderThumbnailUrl.IsNullOrEmpty())
            {
                e.Item.Visible = false;
                return;
            }

            bool   isForSale      = item.IsForSale();
            string detailsPageUrl = this.GetDetailsPageUrl(isForSale);

            HyperLink hlDetails = (HyperLink)e.Item.FindControl("hlDetails");

            hlDetails.NavigateUrl = detailsPageUrl + this.RealEstateManager.GetItemUrl(item);

            Image imgSlider = (Image)e.Item.FindControl("imgSlider");

            imgSlider.AlternateText = item.Title;
            imgSlider.ImageUrl      = sliderPhotoUrl;

            Literal ltrAddress = (Literal)e.Item.FindControl("ltrAddress");

            ltrAddress.Text = item.Address;

            Literal ltrPrice = (Literal)e.Item.FindControl("ltrPrice");

            ltrPrice.Text = item.Price.ToString("n2");

            RadListView featuresList = (RadListView)e.Item.FindControl("FeaturesList");

            featuresList.ItemDataBound += new EventHandler <RadListViewItemEventArgs>(FeaturesList_ItemDataBound);
            featuresList.DataSource     = item.GetTaxons <FlatTaxon>(TaxonType.Features);
            featuresList.DataBind();
        }
コード例 #29
0
        public async Task Attachment_Update_RequestsCorrectResource()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.PUT, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment/1", RestClient.BuildUri(r).AbsoluteUri);
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = ""
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.UpdateAsync(new Picture { Id = 1 });
        }
コード例 #30
0
        public async Task Attachment_CreateLink_RequestsCorrectResource()
        {
            RestClient.RespondWith(r =>
            {
                Assert.Equal(Method.POST, r.Method);
                Assert.Equal("https://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment", RestClient.BuildUri(r).AbsoluteUri);
                return(new Messages {
                    Message = { new Message {
                                    MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711"
                                } }
                });
            });

            var re = new RealEstateItem(new ApartmentRent {
                Id = 4711
            }, Client.Connection);
            await re.Attachments.CreateAsync(new Link { Url = "http://www.example.com" });
        }
コード例 #31
0
        public async Task AttachmentsOrder_Update_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.AttachmentsOrder.UpdateAsync(new AttachmentsOrder.List {
                    AttachmentId = { 3, 2, 1 }
                });
            });
        }
コード例 #32
0
        public async Task Attachment_Create_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.CreateAsync(new Picture {
                    Id = 1
                }, @"..\..\..\test.jpg");
            });
        }
コード例 #33
0
        public async Task Attachment_CreateLink_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.CreateAsync(new Link {
                    Url = "http://www.example.com"
                });
            });
        }
コード例 #34
0
        public async Task Attachment_CreateVideo_ErrorOccurs_ThrowsIS24Exception()
        {
            RestClient.RespondWith(r =>
            {
                return(new RestResponseStub {
                    StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages()
                });
            });

            await AssertEx.ThrowsAsync <IS24Exception>(async() =>
            {
                var video = new StreamingVideo {
                    Title = "Video"
                };
                var re = new RealEstateItem(new ApartmentRent {
                    Id = 4711
                }, Client.Connection);
                await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\..\test.avi");
            });
        }
コード例 #35
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Update_PostsAttachmentObject()
        {
            Http.RespondWith(m =>
            {
                var a = new BaseXmlDeserializer().Deserialize<Attachment>(new RestResponse { Content = Http.RequestBody });
                Assert.IsAssignableFrom<Attachment>(a);
                Assert.Equal(1, a.Id);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.UpdateAsync(new Picture { Id = 1 });
        }
コード例 #36
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Update_CallSucceeds_NoExceptionThrown()
        {
            Http.RespondWith(m =>
            {
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.UpdateAsync(new Picture { Id = 1 });
        }
コード例 #37
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateLink_RequestsCorrectResource()
        {
            Http.RespondWith(m =>
            {
                Assert.Equal("POST", m);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment", Http.Url.AbsoluteUri);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateAsync(new Link { Url = "http://www.example.com" });
        }
コード例 #38
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task AttachmentsOrder_Update_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.AttachmentsOrder.UpdateAsync(new AttachmentsOrder.List { AttachmentId = { 3, 2, 1 } });
            });
        }
コード例 #39
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateLink_PostsAttachmentObject()
        {
            Http.RespondWith(m =>
            {
                var l = new BaseXmlDeserializer().Deserialize<Attachment>(new RestResponse { Content = Http.RequestBody });
                Assert.IsAssignableFrom<Link>(l);
                Assert.Equal("http://www.example.com", ((Link)l).Url);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateAsync(new Link { Url = "http://www.example.com" });
        }
コード例 #40
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Create_HasMetadata()
        {
            Http.RespondWith(m =>
            {
                var meta = Http.Files.Single(f => f.Name == "metadata");
                Assert.Equal("application/xml", meta.ContentType);
                Assert.Equal("body.xml", meta.FileName);
                var ms = new MemoryStream();
                meta.Writer(ms);
                var bytes = ms.ToArray();
                Assert.Equal(bytes.Length, meta.ContentLength);
                var content = Encoding.UTF8.GetString(bytes);
                var a = new BaseXmlDeserializer().Deserialize<Attachment>(new RestResponse { Content = content });
                Assert.IsType<Picture>(a);
                Assert.Equal("Test", a.Title);

                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateAsync(new Picture { Title = "Test" }, @"..\..\test.jpg");
        }
コード例 #41
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Create_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.CreateAsync(new Picture { Id = 1 }, @"..\..\test.jpg");
            });
        }
コード例 #42
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateVideo_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var video = new StreamingVideo { Title = "Video" };
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
            });
        }
コード例 #43
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateVideo_CanDeserializeResponse()
        {
            Http.RespondWith(m =>
            {
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                return "ok";
            }).ThenWith(m =>
            {
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var video = new StreamingVideo { Title = "Video" };
            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
            Assert.Equal(4711, video.Id);
            Assert.Equal("xyz", video.VideoId);
        }
コード例 #44
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateLink_ErrorOccurs_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.CreateAsync(new Link { Url = "http://www.example.com" });
            });
        }
コード例 #45
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateVideo_HasFile()
        {
            var bytes = File.ReadAllBytes(@"..\..\test.avi");

            Http.RespondWith(m =>
            {
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                var file = Http.Files.Single(f => f.Name == "videofile");
                Assert.Equal("application/octet-stream", file.ContentType);
                Assert.Equal("test.avi", file.FileName);
                Assert.Equal(bytes.Length, file.ContentLength);
                var ms = new MemoryStream();
                file.Writer(ms);
                AssertEx.CollectionEqual(bytes, ms.ToArray());
                return "ok";
            }).ThenWith(m =>
            {
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(new StreamingVideo { Title = "Video" }, @"..\..\test.avi");
        }
コード例 #46
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateVideo_RequestsCorrectResource()
        {
            Http.RespondWith(m =>
            {
                Assert.Equal("GET", m);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/videouploadticket", Http.Url.AbsoluteUri);
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                Assert.Equal("POST", m);
                Assert.Equal("secret", Http.Parameters.Single(p => p.Name == "auth").Value);
                Assert.Equal("http://www.example.com/test", Http.Url.AbsoluteUri);
                return "ok";
            }).ThenWith(m =>
            {
                Assert.Equal("POST", m);
                var v = new BaseXmlDeserializer().Deserialize<Attachment>(new RestResponse { Content = Http.RequestBody });
                Assert.Equal("xyz", ((StreamingVideo)v).VideoId);
                Assert.Equal("Video", ((StreamingVideo)v).Title);
                Assert.Equal("http://rest.sandbox-immobilienscout24.de/restapi/api/offer/v1.0/user/me/realestate/4711/attachment", Http.Url.AbsoluteUri);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var video = new StreamingVideo { Title = "Video" };
            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
        }
コード例 #47
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_GetAll_CanDeserializeResponse()
        {
            Http.RespondWith(m =>
            {
                return new Attachments
                {
                    Attachment = {
                        new Attachment { Id = 4711 },
                        new Attachment { Id = 4712 },
                    }
                };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            var a = (await re.Attachments.GetAsync()).ToList();

            Assert.Equal(2, a.Count);
            Assert.Equal(4711, a[0].Id);
            Assert.Equal(4712, a[1].Id);
        }
コード例 #48
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateVideo_ErrorOccursAtPostAttachment_ThrowsIS24Exception()
        {
            Http.RespondWith(m =>
            {
                return new VideoUploadTicket { Auth = "secret", UploadUrl = "http://www.example.com/test", VideoId = "xyz" };
            }).ThenWith(m =>
            {
                return "ok";
            }).ThenWith(m =>
            {
                return new HttpStubResponse { StatusCode = HttpStatusCode.PreconditionFailed, ResponseObject = new Messages() };
            });

            await AssertEx.ThrowsAsync<IS24Exception>(async () =>
            {
                var video = new StreamingVideo { Title = "Video" };
                var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
                await re.Attachments.CreateStreamingVideoAsync(video, @"..\..\test.avi");
            });
        }
コード例 #49
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Create_CanDeserializeResponse()
        {
            Http.RespondWith(m =>
            {
                var msgs = new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
                return msgs;
            });

            var att = new Picture { Title = "Test" };

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateAsync(att, @"..\..\test.jpg");

            Assert.Equal(4711, att.Id);
        }
コード例 #50
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task AttachmentsOrder_Get_CanDeserializeResponse()
        {
            Http.RespondWith(m =>
            {
                return new AttachmentsOrder.List { AttachmentId = { 1, 2, 3 } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 1 }, Client.Connection);
            var list = await re.Attachments.AttachmentsOrder.GetAsync();

            Assert.IsType<AttachmentsOrder.List>(list);
            AssertEx.CollectionEqual<long>(new long[] { 1, 2, 3 }, list.AttachmentId);
        }
コード例 #51
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task AttachmentsOrder_Update_PostsAttachmentObject()
        {
            Http.RespondWith(m =>
            {
                var list = new BaseXmlDeserializer().Deserialize<AttachmentsOrder.List>(new RestResponse { Content = Http.RequestBody });
                Assert.IsAssignableFrom<AttachmentsOrder.List>(list);
                AssertEx.CollectionEqual<long>(new long[] { 3, 2, 1 }, list.AttachmentId);
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_UPDATED, MessageProperty = "" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.AttachmentsOrder.UpdateAsync(new AttachmentsOrder.List { AttachmentId = { 3, 2, 1 } });
        }
コード例 #52
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_CreateLink_CallSucceeds_NoExceptionThrown()
        {
            Http.RespondWith(m =>
            {
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateAsync(new Link { Url = "http://www.example.com" });
        }
コード例 #53
0
ファイル: AttachmentTests.cs プロジェクト: enkol/IS24RestApi
        public async Task Attachment_Create_HasFile()
        {
            var bytes = File.ReadAllBytes(@"..\..\test.jpg");

            Http.RespondWith(m =>
            {
                var file = Http.Files.Single(f => f.Name == "attachment");
                Assert.Equal("image/jpeg", file.ContentType);
                Assert.Equal("test.jpg", file.FileName);
                Assert.Equal(bytes.Length, file.ContentLength);
                var ms = new MemoryStream();
                file.Writer(ms);
                AssertEx.CollectionEqual(bytes, ms.ToArray());
                return new Messages { Message = { new Message { MessageCode = MessageCode.MESSAGE_RESOURCE_CREATED, MessageProperty = "Resource with id [4711] has been created.", Id = "4711" } } };
            });

            var re = new RealEstateItem(new ApartmentRent { Id = 4711 }, Client.Connection);
            await re.Attachments.CreateAsync(new Picture { Title = "Test" }, @"..\..\test.jpg");
        }