Beispiel #1
0
        public async void InitFromPOst(SundihomeApi.Entities.Post post)
        {
            Init();
            CheckLastPost = true;
            ControlSegment.ItemsSource = new List <string> {
                Language.can_ban, Language.cho_thue, Language.can_mua, Language.can_thue
            };
            ControlSegment.SetActive(post.PostType);
            editor.Text = post.Description;

            EntryTitle.Text = post.Title;

            // loai bat dong san
            LookUpType.SelectedItem = loaiBatDongSans.Single(x => x.Id == post.LoaiBatDongSanId);

            // gia
            if (!post.IsNegotiate) // khong phai la thoa thuan
            {
                EntryPrice.Text = post.PriceFrom;

                var priceOption = this.viewModel.PriceOptions.SingleOrDefault(x => x.Id == post.PriceFromUnit);
                if (priceOption != null)
                {
                    pickerUnitPrice.SelectedItem = priceOption;
                }
                else
                {
                    pickerUnitPrice.SelectedItem = this.viewModel.PriceOptions.First();
                }
            }
            else
            {
                pickerUnitPrice.SelectedItem = this.viewModel.PriceOptions.First();
            }

            // dien tich.
            EntryArea.Text = post.AreaFormatText?.Replace("m2", "") ?? "";

            // phong ngu
            if (post.NumOfBedroom.HasValue)
            {
                SoPhongNgu_Tapped(StacklayoutSophongngu.Children[this.NumberList.ToList().IndexOf((int)post.NumOfBedroom)], EventArgs.Empty);
            }

            // phong ta
            if (post.NumOfBathroom.HasValue)
            {
                SoPhongNgu_Tapped(StacklayoutSoPhongtam.Children[this.NumberList.ToList().IndexOf((int)post.NumOfBathroom)], EventArgs.Empty);
            }

            if (!string.IsNullOrEmpty(post.Images))
            {
                ImageList = post.ImageList.ToList();

                foreach (var image in post.ImageList)
                {
                    viewModel.Media.Add(new MediaFile()
                    {
                        PreviewPath = ImageHelper.GetImageUrl("post", image),
                    });
                }
            }
            else
            {
                ImageList = new List <string>();
            }

            EntryPrice.Text = post.PriceFrom;

            await viewModel.GetProvinceAsync();

            viewModel.Province = viewModel.ProvinceList.Single(x => x.Id == post.ProvinceId);
            await viewModel.GetDistrictAsync();

            viewModel.District = viewModel.DistrictList.Single(x => x.Id == post.DistrictId);

            await viewModel.GetWardAsync();

            viewModel.Ward   = viewModel.WardList.Single(x => x.Id == post.WardId);
            viewModel.Street = post.Street;

            loadingPopup.IsVisible = false;
        }
Beispiel #2
0
 public AddPostItemPage(SundihomeApi.Entities.Post post)
 {
     InitializeComponent();
     this.BindingContext = viewModel = new AddPostItemPageViewModel();
     InitFromPOst(post);
 }