Exemplo n.º 1
0
        private async Task <string> SetDivarRegionAsync(BuildingBussines bu)
        {
            var region = "";

            try
            {
                var relatedRegion = await AdvertiseRelatedRegionBussines.GetByRegionGuidAsync(bu.RegionGuid);

                if (relatedRegion != null)
                {
                    region = relatedRegion?.OnlineRegionName ?? "";
                }
                else
                {
                    var reg = await RegionsBussines.GetAsync(bu.RegionGuid);

                    if (reg != null)
                    {
                        region = reg?.Name;
                        if (region.StartsWith(" "))
                        {
                            region = region.Remove(0, 1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(region);
        }
Exemplo n.º 2
0
        private async void btnSeach_Click(object sender, EventArgs e)
        {
            try
            {
                clsAdvertise.MaxFileCount = (int)txtMaxFile.Value;

                var     list = new List <BuildingViewModel>();
                decimal fPrice1 = 0, sPrice1 = 0, fPrice2 = 0, sPrice2 = 0;

                if (cmbRahn1.SelectedIndex == 0)
                {
                    fPrice1 = txtFPrice1.Text.ParseToDecimal() * 10000;
                }
                if (cmbRahn1.SelectedIndex == 1)
                {
                    fPrice1 = txtFPrice1.Text.ParseToDecimal() * 10000000;
                }
                if (cmbRahn1.SelectedIndex == 2)
                {
                    fPrice1 = txtFPrice1.Text.ParseToDecimal() * 10000000000;
                }

                if (cmbRahn2.SelectedIndex == 0)
                {
                    sPrice1 = txtFPrice2.Text.ParseToDecimal() * 10000;
                }
                if (cmbRahn2.SelectedIndex == 1)
                {
                    sPrice1 = txtFPrice2.Text.ParseToDecimal() * 10000000;
                }
                if (cmbRahn2.SelectedIndex == 2)
                {
                    sPrice1 = txtFPrice2.Text.ParseToDecimal() * 10000000000;
                }

                if (cmbEjare1.SelectedIndex == 0)
                {
                    fPrice2 = txtSPrice1.Text.ParseToDecimal() * 10000;
                }
                if (cmbEjare1.SelectedIndex == 1)
                {
                    fPrice2 = txtSPrice1.Text.ParseToDecimal() * 10000000;
                }
                if (cmbEjare1.SelectedIndex == 2)
                {
                    fPrice2 = txtSPrice1.Text.ParseToDecimal() * 10000000000;
                }

                if (cmbEjare2.SelectedIndex == 0)
                {
                    sPrice2 = txtSPrice2.Text.ParseToDecimal() * 10000;
                }
                if (cmbEjare2.SelectedIndex == 1)
                {
                    sPrice2 = txtSPrice2.Text.ParseToDecimal() * 10000000;
                }
                if (cmbEjare2.SelectedIndex == 2)
                {
                    sPrice2 = txtSPrice2.Text.ParseToDecimal() * 10000000000;
                }

                if (chbSystem.Checked)
                {
                    _token?.Cancel();
                    _token = new CancellationTokenSource();
                    list.AddRange(await BuildingBussines.GetAllAsync(txtCode.Text, _token.Token,
                                                                     (Guid)cmbBuildingType.SelectedValue,
                                                                     (Guid)cmbBuildingAccountType.SelectedValue, txtFMasahat.Text.ParseToInt(),
                                                                     txtSMasahat.Text.ParseToInt(), txtRoomCount.Text.ParseToInt(), fPrice1, fPrice2,
                                                                     sPrice1, sPrice2,
                                                                     (EnRequestType)cmbReqType.SelectedIndex, RegionList));
                }

                if (chbDivar.Checked)
                {
                    var list_ = new List <string>();
                    foreach (var item in RegionList)
                    {
                        var related = await AdvertiseRelatedRegionBussines.GetByRegionGuidAsync(item);

                        if (related != null)
                        {
                            list_.Add(related.OnlineRegionName);
                            continue;
                        }

                        var region = await RegionsBussines.GetAsync(item);

                        if (region != null)
                        {
                            list_.Add(region.Name);
                        }
                    }

                    list_ = list_.GroupBy(q => q).Select(q => q.Key).ToList();
                    var divar = DivarAdv.GetInstance();
                    list.AddRange(await divar.GetBuildingAsync((EnRequestType)cmbReqType.SelectedIndex, fPrice1,
                                                               sPrice1, fPrice2, sPrice2, txtFMasahat.Text.ParseToInt(),
                                                               txtSMasahat.Text.ParseToInt(), (int)txtMaxFile.Value, list_));
                }


                var frm = new frmBuildingAdvanceSearch(list);
                frm.ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }