public async Task <QueryResult <BranchModel> > Find(BranchSearchCriteriaModel branchSearchCriteriaModel) { branchSearchCriteriaModel.AgencyCode = User.UserAgency(); var branchList = await _branchService.Find(branchSearchCriteriaModel); return(branchList); }
public async Task ShouldFindBranchBySearchCriteria() { var branchSearchCriteriaModel = new BranchSearchCriteriaModel(); var result = await _sutBranchServiceQueries.Find(branchSearchCriteriaModel); Assert.NotNull(result); Assert.IsType <QueryResult <BranchModel> >(result); }
public async Task <QueryResult <BranchModel> > Find(BranchSearchCriteriaModel criteria) { var result = await _context.Branch.Include(t => t.Agency) .Where(x => x.IsActive == true && x.AgencyCode == criteria.AgencyCode) .WhereIf(!string.IsNullOrEmpty(criteria.BranchName), s => s.BranchName.Contains(criteria.BranchName)) .OrderBy(x => x.BranchId) .SortBy(criteria.Sort, criteria.SortDirection) .Select(x => new BranchModel { AddressesList = x.BranchAddresses.Where(s => s.AddressTypeId != (int)Enums.BranchAddressType.MainBranchAddress).Select(r => new OtherBranchAddressModel { BranchAddressId = r.BranchAddressId, AddressName = r.AddressName, Address = r.Address, CityCode = r.CityCode, Description = r.Description, Email = r.Email, Fax = r.Fax, Fax2 = r.Fax2, Phone = r.Phone, Phone2 = r.Phone2, Position = r.Position, PostalCode = r.PostalCode, ZipCode = r.ZipCode }).ToList(), MainBranchAddress = x.BranchAddresses.Where(s => s.AddressTypeId == (int)Enums.BranchAddressType.MainBranchAddress && s.IsActive == true).Select(m => new MainBranchAddressModel { BranchAddressId = m.BranchAddressId, AddressName = m.AddressName, Address = m.Address, CityCode = m.CityCode, Description = m.Description, Email = m.Email, Fax = m.Fax, Fax2 = m.Fax2, Phone = m.Phone, Phone2 = m.Phone2, Position = m.Position, PostalCode = m.PostalCode, ZipCode = m.ZipCode }).FirstOrDefault() ?? new MainBranchAddressModel(), techcommitteeIds = x.BranchCommittees.Where(d => d.Committee.CommitteeTypeId == (int)Enums.CommitteeType.TechincalCommittee && d.IsActive == true).Select(d => d.CommitteeId).ToList <int>(), checkcommitteeIds = x.BranchCommittees.Where(d => d.Committee.CommitteeTypeId == (int)Enums.CommitteeType.CheckOfferCommittee && d.IsActive == true).Select(d => d.CommitteeId).ToList <int>(), opencommitteeIds = x.BranchCommittees.Where(d => d.Committee.CommitteeTypeId == (int)Enums.CommitteeType.OpenOfferCommittee && d.IsActive == true).Select(d => d.CommitteeId).ToList <int>(), purchaseCommitteeIds = x.BranchCommittees.Where(d => d.Committee.CommitteeTypeId == (int)Enums.CommitteeType.PurchaseCommittee && d.IsActive == true).Select(d => d.CommitteeId).ToList <int>(), preQualificationCommitteeIds = x.BranchCommittees.Where(d => d.Committee.CommitteeTypeId == (int)Enums.CommitteeType.PreQualificationCommittee && d.IsActive == true).Select(d => d.CommitteeId).ToList <int>(), vrocommitteeIds = x.BranchCommittees.Where(d => d.Committee.CommitteeTypeId == (int)Enums.CommitteeType.VROCommittee && d.IsActive == true).Select(d => d.CommitteeId).ToList <int>(), BranchId = x.BranchId, BranchIdString = Util.Encrypt(x.BranchId), BranchName = x.BranchName, AgencyName = x.Agency.NameArabic }).ToQueryResult(criteria.PageNumber, criteria.PageSize); return(result); }
public async Task FindTest() { _claims = new Claim[1] { new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000") }; _branchController = _branchController.WithIdentity(_claims); var requestModel = new BranchSearchCriteriaModel() { }; var response = await _branchController.Find(requestModel); Assert.NotNull(response); Assert.NotEmpty(response.Items); }
public async Task <IActionResult> IndexPagingAsync(BranchSearchCriteriaModel branchSearchCriteria) { try { var blocks = await _ApiClient.GetQueryResultAsync <BranchModel>("Branch/Find", branchSearchCriteria.ToDictionary()); return(Json(new PaginationModel(blocks.Items, blocks.TotalCount, blocks.PageSize, blocks.PageNumber, null))); } catch (AuthorizationException ex) { throw ex; } catch (BusinessRuleException ex) { return(JsonErrorMessage(ex.Message)); } catch (Exception ex) { _logger.LogError(ex.ToString(), ex); return(JsonErrorMessage(Resources.TenderResources.ErrorMessages.UnexpectedError)); } }
public async Task <QueryResult <BranchModel> > Find(BranchSearchCriteriaModel criteria) { Check.ArgumentNotNull(nameof(criteria), criteria); return(await _branchServiceQueries.Find(criteria)); }