Untitled

 avatar
unknown
plain_text
2 years ago
5.7 kB
7
Indexable
var evaluateProperty = (await client
                .Child($"Lessors/{lessorkey}/Properties")
                .OnceAsync<MyListings>()).FirstOrDefault
                (a => a.Object.PropertyName == propname);
                if (evaluateProperty == null)
                {
                    //Save Listing images
                    var _mainimg = await UploadImage(await mainimg.OpenReadAsync(), _propname, $"{propname}_mainimg.png");
                    var _img1 = await UploadImage(await img1.OpenReadAsync(), _propname, $"{propname}_img1.png");
                    var _img2 = await UploadImage(await img2.OpenReadAsync(), _propname, $"{propname}_img2.png");
                    var _img3 = await UploadImage(await img3.OpenReadAsync(), _propname, $"{propname}_img3.png");
                    var _img4 = await UploadImage(await img4.OpenReadAsync(), _propname, $"{propname}_img4.png");
                    var _img5 = await UploadImage(await img5.OpenReadAsync(), _propname, $"{propname}_img5.png");
                    var _img6 = await UploadImage(await img6.OpenReadAsync(), _propname, $"{propname}_img6.png");
                    //Save Listing info.
                    var lessors = new MyListings()
                    {
                        PropertyName = propname,
                        PropertyDescription = propdesc,
                        PropertyStock = propstock,
                        PropMainImage = _mainimg,
                        PropertyCategory = propcategory,
                        PropertyStatus = propstatus,
                        Prop_RentPrice = rentPrice,
                        Prop_RentUnitOfTime = propunitoftime,
                        PropertyDetails = propdetails,
                        Prop_RentDuration = durationunitoftime,
                        PropImg_1 = _img1,
                        PropImg_2 = _img2,
                        PropImg_3 = _img3,
                        PropImg_4 = _img4,
                        PropImg_5 = _img5,
                        PropImg_6 = _img6,
                        PublishStatus = "0"
                    };
                    await client
                        .Child($"Lessors/{lessorkey}/Properties")
                        .PostAsync(lessors);

                    //This line of code will get the key of the property before adding the images for carouselView

                    var getPropertyKey = (await client
                        .Child($"Lessors/{lessorkey}/Properties")
                        .OnceAsync<MyListings>()).FirstOrDefault
                        (a => a.Object.PropertyName == propname);
                    if (getPropertyKey != null)
                    {
                        var b = getPropertyKey.Key;
                        //The following line of code will save the images in the same node with different file names
                        //**********Main image
                        var imgmain = new MyListings()
                        {
                            ImgUrl = _mainimg,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                            .PostAsync(imgmain);
                        //**********1 image
                        var img_1 = new MyListings()
                        {
                            ImgUrl = _img1,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                            .PostAsync(img_1);

                        //**********2 image
                        var img_2 = new MyListings()
                        {
                            ImgUrl = _img2,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                            .PostAsync(img_2);

                        //**********3 image
                        var img_3 = new MyListings()
                        {
                            ImgUrl = _img3,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                            .PostAsync(img_3);
                        //**********4 image
                        var img_4 = new MyListings()
                        {
                            ImgUrl = _img4,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                            .PostAsync(img_4);
                        //**********5 image
                        var img_5 = new MyListings()
                        {
                            ImgUrl = _img5,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                            .PostAsync(img_5);
                        //**********6 image
                        var img_6 = new MyListings()
                        {
                            ImgUrl = _img6,
                        };
                        await client
                            .Child($"Lessors/{lessorkey}/Properties/{b}/CarouselImages/{propname}")
                        .PostAsync(img_6);
                    }
                    client.Dispose();
Editor is loading...