Exemplo n.º 1
0
        private async void Init()
        {
            await viewModel.LoadProject(_id);

            await viewModel.LoadPostProjectID(_id);

            await viewModel.GetListProjectDiary(_id);

            if (viewModel.DuAn.ImageUtilities != null)
            {
                string[]      utilitiesArr = viewModel.DuAn.ImageUtilities.Split(',');
                Option[]      utilitiesImg = new Option[utilitiesArr.Length];
                List <Option> tienichduan  = BDSUtilities.GetListUtilities();
                for (int i = 0; i < utilitiesArr.Length; i++)
                {
                    var    item  = utilitiesArr[i];
                    Option model = tienichduan.Where(x => x.Id == short.Parse(item)).SingleOrDefault();
                    utilitiesImg[i] = model;
                }
                flowListView.FlowItemsSource = utilitiesImg;
                stTienIchDuAn.IsVisible      = true;
            }
            if (viewModel.DuAn.ImageList != null)
            {
                string[] ListImages = viewModel.DuAn.ImageList;
                for (int i = 0; i < ListImages.Length; i++)
                {
                    Photo photo = new Photo();
                    photo.URL = Api_Link + ListImages[i];
                    GetPhotos.Add(photo);
                }
                lbNumImages.Text        = ListImages.Count().ToString();
                carouseView.ItemsSource = GetPhotos;
            }

            if (viewModel.DuAn.CategoriBDS != null)
            {
                string[] categoriArr     = viewModel.DuAn.CategoriBDS.Split(',');
                string[] categoryNameArr = new string[categoriArr.Length];

                //projectType tren app la categoriBDS tren database
                List <ProjectTypeModel> loaiDuAn = ProjectTypeData.GetListProjectType();
                for (int i = 0; i < categoriArr.Length; i++)
                {
                    var item = categoriArr[i];
                    ProjectTypeModel model = loaiDuAn.Where(x => x.Id == short.Parse(item)).SingleOrDefault();
                    categoryNameArr[i] = model.Name;
                }
                lbCategoriBDS.Text = string.Join(". ", categoryNameArr);

                //lay "Status"
                if (viewModel.DuAn.Status.HasValue)
                {
                    int idStatus = viewModel.DuAn.Status.Value;
                    List <ProjectStatusModel> listStatus  = ProjectStatusData.GetList();
                    ProjectStatusModel        modelStatus = listStatus.Single(x => x.Id == idStatus);
                    lbStatus.Text = modelStatus.Name;
                    if (viewModel.DuAn.Status.Value == 0)
                    {
                        stThoiGianMoBan.IsVisible   = true;
                        stThoiGianBanGiao.IsVisible = true;
                    }

                    if (viewModel.DuAn.Status.Value == 1)
                    {
                        stThoiGianBanGiao.IsVisible = true;
                    }
                }
            }

            await ChekcIsFollowPost();

            loadingPopup.IsVisible = false;

            stNamKhoiCong.IsVisible  = true;
            stNamHoanThanh.IsVisible = true;

            // load data "Tong quan du an"
            lbDienTichCayXanh.Text      = viewModel.DuAn.DienTichCayXanh;
            lbDienTichKhuDat.Text       = viewModel.DuAn.DienTichKhuDat;
            lbDienTichSanTrungBinh.Text = viewModel.DuAn.DienTichSanTrungBinh;
            lbDienTichXayDung.Text      = viewModel.DuAn.DienTichXayDung;
            lbNamKhoiCong.Text          = viewModel.DuAn.NamKhoiCong.ToString();
            lbNamHoanThanh.Text         = viewModel.DuAn.NamHoanThanh.ToString();
            lbMatDoXayDung.Text         = viewModel.DuAn.MatDoXayDungPercent.ToString();
            lbSoLuongSanPham.Text       = viewModel.DuAn.SoLuongSanPham;
            lbSoTang.Text               = viewModel.DuAn.SoTang.ToString();
            lbSoLuongToaNha.Text        = viewModel.DuAn.SoLuongToaNha.ToString();
            lbSoThangMay.Text           = viewModel.DuAn.SoThangMay.ToString();
            lbTongDienTichSan.Text      = viewModel.DuAn.TongDienTichSan;
            lbTongSoVongDauTu.Text      = viewModel.DuAn.TongVonDauTu;
            lbTangHam.Text              = viewModel.DuAn.TangHam.ToString();
            lbThoiGianMoBan.Text        = viewModel.DuAn.ThoiGianMoBan.ToString();
            lbThoiGianBanGiao.Text      = viewModel.DuAn.ThoiGianBanGiao.ToString();
            lblChuDauTu.Text            = viewModel.DuAn.ChuDauTu;
            lblDonViThietKeThiCong.Text = viewModel.DuAn.DonViThietKeThiCong;
            lblPhanKhuDuAn.Text         = viewModel.DuAn.PhanKhuDuAn;

            var gridChildren = grContent.Children.Where(x => x.IsVisible == true).ToList();

            for (int i = 0; i < gridChildren.Count(); i++)
            {
                grContent.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(9, GridUnitType.Auto)
                });
                Grid.SetRow(gridChildren[i], i);
            }
        }
Exemplo n.º 2
0
        public async void Init()
        {
            bool HasResult = await viewModel.LoadPost(_id);

            if (!HasResult)
            {
                await DisplayAlert("", Language.bai_dang_khong_ton_tai_hoac_da_xoa, Language.dong);

                await Navigation.PopAsync();

                return;
            }
            // cau hinh button.
            SetFloatingButtonGroup();


            // can thue can mua thi load comment ve. hien thi o comment.
            if (viewModel.GetPost.PostType == 2 || viewModel.GetPost.PostType == 3)
            {
                await viewModel.LoadPostComment();

                StacklayoutPostComments.IsVisible = true;
                onClick_HideShow_Description(null, EventArgs.Empty); // dong lai mo ta. neu post type 2 3
                MessagingCenter.Subscribe <PickPostPage>(this, "OnNewPostComment", async(sender) =>
                {
                    loadingPopup.IsVisible = true;
                    viewModel.PostComments.Clear();
                    viewModel.PostCommentPage = 1;
                    await viewModel.LoadPostComment();
                    loadingPopup.IsVisible = false;
                });
            }
            else
            {
                StacklayoutPostComments.IsVisible = false;
            }

            lbLoaiBatDongSan.Text = LoaiBatDongSanModel.GetList(null).SingleOrDefault(x => x.Id == viewModel.GetPost.LoaiBatDongSanId).Name;

            if (viewModel.GetPost.PostType == 0 || viewModel.GetPost.PostType == 1)
            {
                stListImg.IsVisible = true;
            }


            if (viewModel.GetPost.PostType == 2 || viewModel.GetPost.PostType == 3)
            {
                gridContent.Margin            = new Thickness(0, 10, 0, 0); // đây frame xuong
                cvBDSCungKhuVuc.HeightRequest = 90;
                frContentPost.Margin          = new Thickness(10, 0, 10, 0);
            }

            //lấy danh sách Images
            if (viewModel.GetPost.ImageList != null)
            {
                string[] ListImages = viewModel.GetPost.ImageList;
                for (int i = 0; i < ListImages.Length; i++)
                {
                    Photo photo = new Photo();
                    photo.URL = ImageHelper.GetImageUrl("post", ListImages[i]);
                    GetPhotos.Add(photo);
                }
                lbNumImages.Text        = ListImages.Count().ToString();
                carouseView.ItemsSource = GetPhotos;
            }

            if (viewModel.GetPost.TinhTrangPhapLyId.HasValue)
            {
                var TinhTrangPhapLy = viewModel.GetPost.TinhTrangPhapLyId;
                List <TinhTrangPhapLyModel> tinhtrangphaplyModel = TinhTrangPhapLyData.GetList();
                TinhTrangPhapLyModel        modelTinhTrangPhapLy = tinhtrangphaplyModel.Where(x => x.Id == TinhTrangPhapLy).SingleOrDefault();
                lbTinhTrangPhapLy.Text = modelTinhTrangPhapLy.Name;
            }

            if (viewModel.GetPost.HuongId.HasValue)
            {
                var HuongNha = viewModel.GetPost.HuongId;
                List <HuongModel> huongnhaModel = HuongData.GetList();
                HuongModel        modelHuong    = huongnhaModel.Where(x => x.Id == HuongNha).SingleOrDefault();
                lbHuongNha.Text = modelHuong.Name;
            }

            //set trang thai duu an.
            if (viewModel.GetPost.Project?.Status != null)
            {
                int id_Status = viewModel.GetPost.Project.Status.Value;
                List <ProjectStatusModel> listStatus  = ProjectStatusData.GetList();
                ProjectStatusModel        modelStatus = listStatus.Single(x => x.Id == id_Status);
                spStatus.Text = modelStatus.Name;
            }


            //kiểm tra là lấy thông tin của "nội thất tiện nghi"
            if (viewModel.GetPost.Utilities != null)
            {
                string[]      utilitiesArr = viewModel.GetPost.Utilities.Split(',');
                Option[]      utilitiesImg = new Option[utilitiesArr.Length];
                List <Option> tienichduan  = BDSUtilities.GetListUtilities();
                for (int i = 0; i < utilitiesArr.Length; i++)
                {
                    var    item  = utilitiesArr[i];
                    Option model = tienichduan.Where(x => x.Id == short.Parse(item)).SingleOrDefault();
                    utilitiesImg[i] = model;
                }
                flvUtilities.FlowItemsSource = utilitiesImg;
                stNoiThatTienNghi.IsVisible  = true;
            }
            else
            {
                stNoiThatTienNghi.IsVisible = false;
            }

            //kiểm tra. nếu có projectId thì cho hiện "Thuộc dự an" và lấy loại bất động sản
            if (viewModel.GetPost.ProjectId.HasValue)
            {
                //
                stThuocDuAn.IsVisible = true;
                Guid _idProject = viewModel.GetPost.ProjectId.Value;
                await viewModel.LoadBDSKhac(_id, _idProject);

                if (viewModel.BDSKhac.Count != 0)
                {
                    stBDSKhac.IsVisible = true;
                }

                // lấy loại bất động sản
                string[] categoriArr    = viewModel.GetPost.Project.CategoriBDS.Split(',');
                string[] newCategoriArr = new string[categoriArr.Length];

                List <ProjectTypeModel> modelCategori = ProjectTypeData.GetListProjectType();
                for (int i = 0; i < categoriArr.Length; i++)
                {
                    var temp = categoriArr[i];
                    ProjectTypeModel categoriModel = modelCategori.Where(x => x.Id == short.Parse(temp)).SingleOrDefault();
                    newCategoriArr[i] = categoriModel.Name;
                }

                lbCatogoriBDS.Text = string.Join(", ", newCategoriArr);
            }

            //gán dữ liệ cho label
            lbTongDienTichSuDung.Text = viewModel.GetPost.AreaFormatText;
            lbDuongVao.Text           = viewModel.GetPost.DuongVao.ToString();
            lbMatTien.Text            = viewModel.GetPost.MatTien.ToString();
            lbChieuSau.Text           = viewModel.GetPost.ChieuSau.ToString();
            lbTang.Text       = viewModel.GetPost.Tang.ToString();
            lbSoTang.Text     = viewModel.GetPost.NumOfFloor.ToString();
            lbSoThangMay.Text = viewModel.GetPost.SoThangMay.ToString();
            lbSoDuongNgu.Text = viewModel.GetPost.NumOfBedroom.ToString();
            lbSoPhongtam.Text = viewModel.GetPost.NumOfBathroom.ToString();

            // hiển thị thông tin trong phần "tổng quan dự án" (những thông tin luôn hiện)
            stTinhTrangPhapLy.IsVisible    = true;
            stHuongNha.IsVisible           = true;
            stTongDienTichSuDung.IsVisible = true;

            //hiển thị thông tin trong phần "tổng quan dự án" (kiểm tra theo loại bất động sản)
            var LoaiBatDongSan = viewModel.GetPost.LoaiBatDongSanId;

            if (LoaiBatDongSan == 0)
            {
                stTang.IsVisible       = true;
                stSoPhongTam.IsVisible = true;
                stSoDuongNgu.IsVisible = true;
            }

            if (LoaiBatDongSan == 1)
            {
                stTang.IsVisible       = true;
                stSoPhongTam.IsVisible = true;
                stSoDuongNgu.IsVisible = true;
            }

            if (LoaiBatDongSan == 2)
            {
                stDuongVao.IsVisible   = true;
                stMatTien.IsVisible    = true;
                stSoTang.IsVisible     = true;
                stSoPhongTam.IsVisible = true;
                stSoDuongNgu.IsVisible = true;
            }

            if (LoaiBatDongSan == 3)
            {
                stDuongVao.IsVisible   = true;
                stMatTien.IsVisible    = true;
                stSoTang.IsVisible     = true;
                stSoPhongTam.IsVisible = true;
                stSoDuongNgu.IsVisible = true;
            }

            if (LoaiBatDongSan == 4)
            {
                stDuongVao.IsVisible   = true;
                stMatTien.IsVisible    = true;
                stSoTang.IsVisible     = true;
                stSoPhongTam.IsVisible = true;
                stSoDuongNgu.IsVisible = true;
            }

            if (LoaiBatDongSan == 5)
            {
                stTang.IsVisible = true;
            }

            if (LoaiBatDongSan == 6)
            {
                stTang.IsVisible       = true;
                stSoThangMay.IsVisible = true;
            }

            if (LoaiBatDongSan == 7)
            {
                stDuongVao.IsVisible   = true;
                stMatTien.IsVisible    = true;
                stSoTang.IsVisible     = true;
                stSoPhongTam.IsVisible = true;
                stSoDuongNgu.IsVisible = true;
            }

            if (LoaiBatDongSan == 8)
            {
                stDuongVao.IsVisible = true;
                stMatTien.IsVisible  = true;
                stChieuSau.IsVisible = true;
            }

            if (LoaiBatDongSan == 9)
            {
                stDuongVao.IsVisible = true;
                stMatTien.IsVisible  = true;
                stChieuSau.IsVisible = true;
            }

            if (LoaiBatDongSan == 10)
            {
                stDuongVao.IsVisible = true;
                stMatTien.IsVisible  = true;
                stChieuSau.IsVisible = true;
            }

            var gridChildren = gridContent.Children.Where(x => x.IsVisible == true).ToList();

            for (int i = 0; i < gridChildren.Count(); i++)
            {
                gridContent.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(9, GridUnitType.Auto)
                });

                Grid.SetRow(gridChildren[i], i);
            }

            //check follow
            await ChekcIsFollowPost();

            //disable loading
            loadingPopup.IsVisible          = false;
            ScrollView_Detail_M_B.IsVisible = true;
        }