private async Task <IEnumerable <Contract> > GetDuplicateModelsEf(DuplicateContractAsyncRequest request) { IEnumerable <Contract> items; if (request.ActionName == DuplicateNameAction.Create) { items = await dataRepository.GetAsync(r => request.CompanyId == r.CompanyId); } else { items = await dataRepository.GetAsync(r => request.CompanyId == r.CompanyId && request.ContractId != r.Id); } return(items.Where(r => request.RenewalDate >= r.RenewalDate && request.RenewalDate <= r.EndDate || request.EndDate >= r.RenewalDate && request.EndDate <= r.EndDate)); }
protected EngineTestBase() { contractList = new List <Contract> { new Contract { Id = 1, CompanyId = 1, DateSigned = DateTime.Parse("18/01/2017", new CultureInfo("en-AU", false)), RenewalDate = DateTime.Parse("18/01/2017", new CultureInfo("en-AU", false)), EndDate = DateTime.Parse("18/01/2018", new CultureInfo("en-AU", false)), Price = 100, ContractType = "Master contact" }, new Contract { Id = 2, CompanyId = 1, DateSigned = DateTime.Parse("19/01/2018", new CultureInfo("en-AU", false)), RenewalDate = DateTime.Parse("19/01/2018", new CultureInfo("en-AU", false)), EndDate = DateTime.Parse("19/01/2019", new CultureInfo("en-AU", false)), Price = 100, ContractType = "Standard contact" } }; contractRepository = Substitute.For <IDataRepositorySoftDeleteInt <Contract> >(); contractRepository.GetAsync(Arg.Any <Expression <Func <Contract, bool> > >()).Returns(contractList); }
private async Task <IEnumerable <BarangaySuggestion> > DoGetBarangaySuggestionsAsync(string search) { search = search.Trim().ToLower(); Expression <Func <Barangay, bool> > whereClause = r => search == "" || r.Name.ToLower().Contains(search); IQueryable <Barangay> EagerLoad(IQueryable <Barangay> r) => r.Include(a => a.CityMunicipality.Province.Region); var results = await barangayRepository.GetAsync(EagerLoad, whereClause, r => r.OrderBy(s => s.Name), 1); var suggestions = results.Select(b => b.CreateSuggestion()); return(suggestions); }
protected override async Task <IPagedList <Address> > GetItemsAsync(int parentId, int page, bool isDesc, int sortColumn, string search, string param) { search = search.Trim().ToLower(); Expression <Func <Address, bool> > whereClause = r => search == "" || r.StreetAddress.ToLower().Contains(search); if (parentId != default) { whereClause = whereClause.And(r => r.OwnerId == parentId); if (param != null) { whereClause = whereClause.And(r => r.OwnerType == param); } } var orderBy = GetOrderBy(sortColumn, isDesc); var result = await repository.GetPagedListAsync(page, whereClause, orderBy); var previousOwnerId = 0; var canFetch = false; var displayName = ""; await result.ForEachAsync(async r => { canFetch = previousOwnerId != r.OwnerId; var ownerType2 = (eAddressOwnerType)Enum.Parse(typeof(eAddressOwnerType), r.OwnerType); switch (ownerType2) { case eAddressOwnerType.Employee: if (canFetch) { var ownerId = r.OwnerId ?? 0; var employee = await employeeRepository.GetAsync(ownerId); displayName = employee?.DisplayName; } r.OwnerDisplayName = displayName; break; case eAddressOwnerType.Dependent: if (canFetch) { var ownerId = r.OwnerId ?? 0; var dependent = await dependentRepository.GetAsync(ownerId); displayName = dependent?.DisplayName; } r.OwnerDisplayName = displayName; break; case eAddressOwnerType.Education: r.OwnerDisplayName = "Education Not yet implemented"; break; case eAddressOwnerType.Office: r.OwnerDisplayName = "Office Not yet implemented"; break; case eAddressOwnerType.Business: r.OwnerDisplayName = "Business Not yet implemented"; break; default: //TODO merge with others: Dependent, Education, Office break; } }); return(result); }