private async Task LoadBranches(int countryId = 0) { var countryList = await _countryService.Get <List <CountryModel> >(null); if (countryId != 0) { var request = new BranchSearchRequest { CountryId = countryId }; var branchesList = await _branchService.Get <List <BranchModel> >(request); var result = GenerateResult(branchesList, countryList); dgvBranch.AutoGenerateColumns = false; dgvBranch.DataSource = result; } else { var branchesList = await _branchService.Get <List <BranchModel> >(null); var result = GenerateResult(branchesList, countryList); dgvBranch.AutoGenerateColumns = false; dgvBranch.DataSource = result; } }
private async void BtnSearch_Click(object sender, EventArgs e) { BranchSearchRequest request = new BranchSearchRequest { Name = txtName.Text, Title = txtTitle.Text }; var result = await _branchService.GetAll <List <Model.Branch> >(request); dgvBranchesData.AutoGenerateColumns = false; dgvBranchesData.DataSource = result; }
private async void btnSaveBranch_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { var branch = new BranchUpsert() { BranchName = txtBranchName.Text, PhoneNumber = txtPhoneNumber.Text, Adress = txtAdress.Text, OpenTime = txtOpenTime.Text, CloseTime = txtClosedTime.Text, Description = txtDescription.Text }; var idCity = cmbCity.SelectedValue; if (int.TryParse(idCity.ToString(), out int cityid)) { branch.CityId = cityid; } var search = new BranchSearchRequest { PhoneNumber = txtPhoneNumber.Text }; var list = await _serviceBranch.Get <List <Data.Model.Branch> >(search); if (list.Count >= 1) { MessageBox.Show("Branch with this phonenumber already exists, please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { await _serviceBranch.Insert <Data.Model.Branch>(branch); MessageBox.Show("Operation successfully completed", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } }