コード例 #1
0
        public async void Init()
        {
            await LoadDetailCompany();

            this.Title = Company.Name;
            this.MainCompanyContentView.Content = new CompanyInfoContentView(this.Company);
            SetVisibleEditCompanyDetail();

            ControlSegment.ItemsSource = new List <string>()
            {
                Language.cong_ty, Language.san_pham, Language.hinh_anh
            };
            ControlSegment.SetActive(0);

            MessagingCenter.Subscribe <AddCompanyPage>(this, "OnSaveCompany", async(sender) =>
            {
                // chi co thong tin va hinh anh thay doi. cho nen set null lai.
                MainCompanyContentView.Content = null;
                MainImagesContentView.Content  = null;
                await LoadDetailCompany(); // load lai thong tin cong ty

                // goi ham nay de quay ve tab thong tin cong ty
                //Company_Clicked(BtnCompany, EventArgs.Empty);
            });

            loadingPopup.IsVisible = false;
        }
コード例 #2
0
 public AddPostItemPage()
 {
     InitializeComponent();
     this.BindingContext        = viewModel = new AddPostItemPageViewModel();
     ControlSegment.ItemsSource = new List <string> {
         Language.can_thanh_ly, Language.can_mua
     };
     ControlSegment.SetActive(0);
     Init();
 }
コード例 #3
0
 public B2BAddPage()
 {
     InitializeComponent();
     this.BindingContext        = viewModel = new B2BAddPageViewModel();
     ControlSegment.ItemsSource = new List <string> {
         Language.hop_tac, Language.cung_cap
     };
     ControlSegment.SetActive(0);
     ImageList = new List <string>();
     Init();
 }
コード例 #4
0
 public AddPostItemPage()
 {
     InitializeComponent();
     this.BindingContext          = viewModel = new AddPostItemPageViewModel();
     pickerUnitPrice.SelectedItem = this.viewModel.PriceOptions.First(); //set mac dinh vnd.
     ControlSegment.ItemsSource   = new List <string> {
         Language.can_ban, Language.cho_thue, Language.can_mua, Language.can_thue
     };
     ControlSegment.SetActive(0);
     ImageList = new List <string>();
     InitAdd();
 }
コード例 #5
0
        public void Segment_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            MainCompanyContentView.IsVisible = false;
            MainProductContentView.IsVisible = false;
            MainImagesContentView.IsVisible  = false;

            var index = ControlSegment.GetCurrentIndex();

            if (index == 0)
            {
                if (this.MainCompanyContentView.Content == null)
                {
                    this.MainCompanyContentView.Content = new CompanyInfoContentView(this.Company);
                }
                MainCompanyContentView.IsVisible = true;
            }
            else if (index == 1)
            {
                if (this.MainProductContentView.Content == null)
                {
                    this.MainProductContentView.Content = new ProductContentView(_compnayId);
                }
                MainProductContentView.IsVisible = true;
            }
            else
            {
                if (this.MainImagesContentView.Content == null)
                {
                    if (this.Company.ImagesList != null)
                    {
                        var imageList = new string[this.Company.ImagesList.Length];
                        for (int i = 0; i < Company.ImagesList.Length; i++)
                        {
                            imageList[i] = ApiConfig.CloudStorageApiCDN + "/company/" + Company.ImagesList[i];
                        }

                        this.MainImagesContentView.Content = new CompanyImageListContentView(imageList);
                    }
                }
                MainImagesContentView.IsVisible = true;
            }
        }
コード例 #6
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;
        }
コード例 #7
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            // truong hop dang them tu bên post .
            if (CheckLastPost)
            {
                if (postItemService == null)
                {
                    postItemService = DependencyService.Get <IPostItemService>();
                }

                DateTime?lastTime = postItemService.GatLastPostTime(UserLogged.Id);
                if (lastTime.HasValue)
                {
                    var      now      = DateTime.Now;
                    TimeSpan timeSpan = now.Subtract(lastTime.Value);
                    if (timeSpan.TotalMinutes >= 120)
                    {
                    }
                    else
                    {
                        //Mỗi bài đăng từ tin đăng phải cách 2 tiếng! Vui lòng thử lại.
                        await DisplayAlert("", Language.moi_bai_dang_phai_tu_it_nhat_x_tieng, Language.dong);

                        return;
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(EntryTitle.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_tieu_de, Language.dong);

                return;
            }

            if (string.IsNullOrWhiteSpace(editor.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_noi_dung, Language.dong);

                return;
            }

            loadingPopup.IsVisible = true;
            // kiem tra co hinh thi upload.
            if (viewModel.Media.Count > 0)
            {
                if (viewModel.Media.Count > 9)
                {
                    loadingPopup.IsVisible = false;
                    await DisplayAlert("", Language.vui_long_chon_toi_da_9_anh, Language.dong);

                    return;
                }

                List <MediaFile> listUploadMedia = viewModel.Media.Where(x => x.Path != null).ToList();
                if (listUploadMedia.Any())
                {
                    MultipartFormDataContent form = new MultipartFormDataContent();
                    for (int i = 0; i < listUploadMedia.Count; i++)
                    {
                        string imageName = $"postitem_{Guid.NewGuid().ToString()}.jpg";
                        ImageList.Add(imageName);

                        var media   = listUploadMedia[i];
                        var stream  = new MemoryStream(File.ReadAllBytes(media.Path));
                        var content = new StreamContent(stream);
                        content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
                        {
                            Name     = "files" + i,
                            FileName = imageName
                        };
                        form.Add(content);
                    }

                    var uploadResonse = await UploadImage(form);

                    if (!uploadResonse.IsSuccess)
                    {
                        loadingPopup.IsVisible = false;
                        await DisplayAlert("", uploadResonse.Message, Language.dong);

                        return;
                    }
                }
            }


            PostItem item = new PostItem();

            item.Title       = EntryTitle.Text.Trim();
            item.Type        = ControlSegment.GetCurrentIndex();
            item.Description = editor.Text;
            item.Images      = ImageList.Any() ? ImageList.ToArray() : null;
            item.CreatedById = UserLogged.Id;
            item.CreatedBy   = new PostItemUser()
            {
                UserId   = UserLogged.Id,
                FullName = UserLogged.FullName,
                Avatar   = UserLogged.AvatarUrl.Replace(ApiConfig.IP2, "")
            };
            item.CreatedDate = DateTime.Now;
            item.HasImage    = ImageList != null && ImageList.Count() > 0;

            // gia
            if (EntryPrice.Text.HasValue)
            {
                item.HasPrice = true;
                item.Price    = DecimalHelper.ToCurrency(EntryPrice.Text.Value) + " " + (pickerUnitPrice.SelectedItem != null ? ((PriceOption)pickerUnitPrice.SelectedItem).Name.ToLower() : "");
            }
            // dien tich
            if (!string.IsNullOrWhiteSpace(EntryArea.Text))
            {
                item.HasArea = true;
                item.Area    = EntryArea.Text + "m2";
            }

            if (!string.IsNullOrWhiteSpace(viewModel.Address))
            {
                item.HasAddress = true;
                item.Address    = viewModel.Address;
            }

            if (viewModel.Province != null)
            {
                item.ProvinceId = viewModel.Province.Id;

                if (viewModel.District != null)
                {
                    item.DistrictId = viewModel.District.Id;

                    if (viewModel.Ward != null)
                    {
                        item.WardId = viewModel.Ward.Id;
                    }
                }
            }

            if (LookUpType.SelectedItem != null)
            {
                var loaiBatDongSan = LookUpType.SelectedItem as LoaiBatDongSanModel;
                item.HasLoaiBatDongSan = true;
                item.BDSTypeId         = loaiBatDongSan.Id;
            }

            if (CheckSelected(StacklayoutSoPhongtam))
            {
                item.HasSoPhongTam = true;
                RadBorder radBorder = GetRadBorder(StacklayoutSoPhongtam);
                var       label     = radBorder.Content as Label;
                item.SoPhongTam = int.Parse(label.Text);
            }

            if (CheckSelected(StacklayoutSophongngu))
            {
                item.HasSoPhongNgu = true;
                RadBorder radBorder = GetRadBorder(StacklayoutSophongngu);
                var       label     = radBorder.Content as Label;
                item.SoPhongNgu = int.Parse(label.Text);
            }

            if (postItemService == null)
            {
                postItemService = DependencyService.Get <IPostItemService>();
            }

            postItemService.AddPostItem(item);
            MessagingCenter.Send <AddPostItemPage, PostItem>(this, "AddPostItemSuccess", item);
            loadingPopup.IsVisible = false;
            await Navigation.PopAsync();

            ToastMessageHelper.ShortMessage(Language.luu_thanh_cong);
        }
コード例 #8
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(EntryTitle.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_tieu_de, Language.dong);

                return;
            }
            else if (string.IsNullOrWhiteSpace(editor.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_noi_dung, Language.dong);

                return;
            }


            loadingPopup.IsVisible = true;
            // kiem tra co hinh thi upload.
            if (viewModel.Media.Count > 0)
            {
                if (viewModel.Media.Count > 9)
                {
                    loadingPopup.IsVisible = false;
                    await DisplayAlert("", Language.vui_long_chon_toi_da_9_anh, Language.dong);

                    return;
                }

                List <MediaFile> listUploadMedia = viewModel.Media.Where(x => x.Path != null).ToList();
                if (listUploadMedia.Any())
                {
                    MultipartFormDataContent form = new MultipartFormDataContent();
                    for (int i = 0; i < listUploadMedia.Count; i++)
                    {
                        string imageName = $"postitem_{Guid.NewGuid().ToString()}.jpg";
                        ImageList.Add(imageName);

                        var media   = listUploadMedia[i];
                        var stream  = new MemoryStream(File.ReadAllBytes(media.Path));
                        var content = new StreamContent(stream);
                        content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
                        {
                            Name     = "files" + i,
                            FileName = imageName
                        };
                        form.Add(content);
                    }

                    var uploadResonse = await UploadImage(form);

                    if (!uploadResonse.IsSuccess)
                    {
                        loadingPopup.IsVisible = false;
                        await DisplayAlert("", uploadResonse.Message, Language.dong);

                        return;
                    }
                }
            }

            #region address

            List <string> addressList = new List <string>();
            if (!string.IsNullOrWhiteSpace(EntryStreet.Text))
            {
                addressList.Add(EntryStreet.Text.Trim());
            }

            if (viewModel.Ward != null)
            {
                addressList.Add(viewModel.Ward.Name);
            }

            if (viewModel.District != null)
            {
                addressList.Add(viewModel.District.Name);
            }

            if (viewModel.Province != null)
            {
                addressList.Add(viewModel.Province.Name);
            }
            string Address = string.Join(", ", addressList.ToArray());
            #endregion



            B2BPostItem item = new B2BPostItem();
            //item.Type = SegmentType.SelectedIndex;
            item.Type        = ControlSegment.GetCurrentIndex();
            item.Title       = EntryTitle.Text.Trim();
            item.Description = editor.Text.Trim();
            item.Images      = ImageList.Any() ? ImageList.ToArray() : null;
            item.CreatedById = UserLogged.Id;
            item.CreatedBy   = new PostItemUser()
            {
                UserId   = UserLogged.Id,
                FullName = UserLogged.FullName,
                Avatar   = UserLogged.AvatarUrl.Replace(ApiConfig.IP2, "")
            };
            item.CreatedDate = DateTime.Now;
            item.HasImage    = ImageList != null && ImageList.Count() > 0;

            if (viewModel.Province != null)
            {
                item.ProvinceId = viewModel.Province.Id;
                if (viewModel.District != null)
                {
                    item.DistrictId = viewModel.District.Id;
                    if (viewModel.Ward != null)
                    {
                        item.WardId = viewModel.Ward.Id;
                    }
                }
            }

            item.Address    = Address;
            item.HasAddress = !string.IsNullOrWhiteSpace(Address);

            #region price
            if (SwitchIsNegotiate.IsToggled)
            {
                item.HasPrice  = true;
                item.PriceText = Language.thoa_thuan;
            }
            else
            {
                List <string> PriceList = new List <string>();
                if (SwitchIsPriceRange.IsToggled)
                {
                    if (EntryPriceFrom.Text.HasValue && EntryPriceFrom.Text.Value > 0)
                    {
                        PriceList.Add(string.Format("{0:0,0 đ}", EntryPriceFrom.Text));
                    }

                    if (EntryPriceTo.Text.HasValue && EntryPriceTo.Text.Value > 0)
                    {
                        PriceList.Add(string.Format("{0:0,0 đ}", EntryPriceTo.Text));
                    }
                }
                else
                {
                    if (EntryPrice.Text.HasValue && EntryPrice.Text.Value > 0)
                    {
                        PriceList.Add(string.Format("{0:0,0 đ}", EntryPrice.Text));
                    }
                }

                if (PriceList.Any())
                {
                    item.HasPrice  = true;
                    item.PriceText = string.Join(" - ", PriceList.ToArray());
                }
            }
            #endregion

            postItemService.AddPostItem(item);
            MessagingCenter.Send <B2BAddPage, B2BPostItem>(this, "AddPostItemSuccess", item);
            loadingPopup.IsVisible = false;
            await Navigation.PopAsync();

            ToastMessageHelper.ShortMessage(Language.dang_thanh_cong);
        }
コード例 #9
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(EntryTitle.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_tieu_de_bai_dang, Language.dong);

                return;
            }
            if (string.IsNullOrEmpty(editor.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_mo_ta_bai_dang, Language.dong);

                return;
            }

            loadingPopup.IsVisible = true;
            MultipartFormDataContent form = new MultipartFormDataContent();

            string[] imageList = null;

            // kiem tra co hinh thi upload.
            if (viewModel.Media.Count > 0)
            {
                if (viewModel.Media.Count > 9)
                {
                    loadingPopup.IsVisible = false;
                    await DisplayAlert("", Language.vui_long_chon_toi_da_9_anh, Language.dong);

                    return;
                }

                imageList = new string[viewModel.Media.Count];
                for (int i = 0; i < viewModel.Media.Count; i++)
                {
                    var media = viewModel.Media[i];
                    // chua upload. upload roi link = null
                    if (string.IsNullOrEmpty(media.Path) == false) // co link la co chon tu dien thoai.
                    {
                        imageList[i] = $"{Guid.NewGuid().ToString()}.jpg";
                        var stream  = new System.IO.MemoryStream(File.ReadAllBytes(media.Path));
                        var content = new StreamContent(stream);
                        content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
                        {
                            Name     = "files" + i,
                            FileName = imageList[i]
                        };
                        form.Add(content);
                    }
                }

                var uploadResponse = await UploadImage(form);

                if (uploadResponse.IsSuccess == false)
                {
                    loadingPopup.IsVisible = false;
                    await DisplayAlert("", Language.loi_upload_hinh_anh_vui_long_thu_lai, Language.dong);

                    return;
                }
            }

            LiquidationPostItem item = new LiquidationPostItem();

            item.Title       = EntryTitle.Text;
            item.Type        = ControlSegment.GetCurrentIndex();
            item.Description = editor.Text;
            item.Images      = imageList;
            item.CreatedById = UserLogged.Id;
            item.CreatedBy   = new PostItemUser()
            {
                UserId   = UserLogged.Id,
                FullName = UserLogged.FullName,
                Avatar   = UserLogged.AvatarUrl.Replace(ApiConfig.IP2, "")
            };
            item.CreatedDate = DateTime.Now;
            item.HasImage    = imageList != null && imageList.Length > 0;

            if (EntryPrice.Text.HasValue)
            {
                item.HasPrice = true;
                item.Price    = DecimalHelper.ToCurrency(EntryPrice.Text.Value) + " đ";
            }

            if (viewModel.Province != null)
            {
                item.ProvinceId = viewModel.Province.Id;
                if (viewModel.District != null)
                {
                    item.DistrictId = viewModel.District.Id;
                    if (viewModel.Ward != null)
                    {
                        item.WardId = viewModel.Ward.Id;
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(viewModel.Address))
            {
                item.HasAddress = true;
                item.Address    = viewModel.Address;
            }

            if (viewModel.Category != null)
            {
                item.HasCategory  = true;
                item.CategoryName = viewModel.Category.Name;
            }

            ILiquidationPostItemService postItemService = DependencyService.Get <ILiquidationPostItemService>();

            postItemService.AddPostItem(item);
            MessagingCenter.Send <AddPostItemPage, LiquidationPostItem>(this, "AddPostItemSuccess", item);
            loadingPopup.IsVisible = false;
            await Navigation.PopAsync();
        }