public List <ProtectionDocEarlyReg> GetProtectionDocEarlyRegs(List <int> protectionDocIds) { var protectionDocEarlyRegs = _context.WtPtEarlyRegs .AsNoTracking() .Where(r => protectionDocIds.Contains(r.DOC_ID ?? 0) && r.ETYPE_ID != null) .ToList(); var oldCountriesIds = protectionDocEarlyRegs.Where(d => d.REQ_COUNTRY != null).Select(d => d.REQ_COUNTRY.GetValueOrDefault(0)).Distinct().ToList(); var countries = _dictionaryTypesHelper.GetCountryIds(oldCountriesIds); return(protectionDocEarlyRegs.Select(r => new ProtectionDocEarlyReg { ProtectionDocId = r.DOC_ID.Value, EarlyRegTypeId = r.ETYPE_ID.Value, DateCreate = r.date_create ?? DateTimeOffset.Now, DateUpdate = r.date_create ?? DateTimeOffset.Now, DateF1 = r.DATE_F1, DateF2 = r.DATE_F2, Description = r.DESCRIPTION, NameSD = r.SA_NAME, RegCountryId = countries.Any(d => d == r.REQ_COUNTRY) ? r.REQ_COUNTRY : null, RegDate = r.REQ_DATE, RegNumber = r.REQ_NUMBER, PCTType = r.PCTYPE }).ToList()); }
public List <DocumentEarlyReg> GetDocumentEarlyRegs(List <int> documentIds) { var documentEarlyRegs = _context.WtPtEarlyRegs .AsNoTracking() .Where(re => documentIds.Contains(re.DOC_ID ?? 0) && re.ETYPE_ID != null) .OrderBy(re => re.U_ID) .ToList(); var oldCountriesIds = documentEarlyRegs.Where(d => d.REQ_COUNTRY != null).Select(d => d.REQ_COUNTRY.GetValueOrDefault(0)).Distinct().ToList(); var countries = _dictionaryTypesHelper.GetCountryIds(oldCountriesIds); return(documentEarlyRegs.Select(de => new DocumentEarlyReg { Id = de.U_ID, DocumentId = de.DOC_ID.Value, EarlyRegTypeId = de.ETYPE_ID.Value, CountryId = countries.Any(d => d == de.REQ_COUNTRY) ? de.REQ_COUNTRY : null, RegNumber = de.REQ_NUMBER, NameSD = de.SA_NAME, RegDate = de.REQ_DATE }).ToList()); }
public (List <DicCustomer> customers, List <CustomerAttorneyInfo> customerAttorneyInfos) GetDicCustomersAndCustomerAttorneyInfos(int packageSize, int lastId) { var oldCustomers = _context.WtCustomers .AsNoTracking() .OrderBy(c => c.Id) .Where(c => c.Id != 0 && c.Id > lastId) .Take(packageSize) .ToList(); var oldCountriesIds = oldCustomers.Where(d => d.CountryId != null).Select(d => d.CountryId.GetValueOrDefault(0)).Distinct().ToList(); var countries = _dictionaryTypesHelper.GetCountryIds(oldCountriesIds); var customers = oldCustomers.Select(c => new DicCustomer { Id = c.Id, TypeId = c.TypeId, IsSMB = CustomConverter.StringToNullableBool(c.flIsSmb), Xin = c.flXIN, NameEn = c.CusNameMlEn, NameEnLong = c.CusNameMlEnLong, NameKz = c.CusNameMlKz, NameKzLong = c.CusNameMlKzLong, NameRu = c.CusNameMlRu, NameRuLong = c.CusNameMlRuLong, ShortDocContent = c.flShortDocContent, Rnn = c.RTN, ContactName = c.ContactFace, CountryId = countries.Any(d => d == c.CountryId) ? c.CountryId : null, Email = c.EMail, PhoneFax = c.Fax, ApplicantsInfo = c.flApplicantsInfo, CertificateNumber = c.flCertificateNumber, CertificateSeries = c.flCertificateSeries, NotaryName = c.flNotaryName, Opf = c.flOpf, PowerAttorneyDateIssue = c.flPowerAttorneyDateIssue, PowerAttorneyFullNum = c.flPowerAttorneyFullNum, RegDate = c.flRegDate, JurRegNumber = c.JurRegNumber, Login = c.Login, Password = c.Password_, Phone = c.Phone, Subscript = c.Subscript, }).ToList(); var customerAttorneyInfos = oldCustomers.Select(c => new CustomerAttorneyInfo { RegCode = c.AttCode, DateBeginStop = c.AttDateBeginStop, DateCard = c.AttDateCard, DateDisCard = c.AttDateDiscard, DateEndStop = c.AttDateEndStop, Education = c.AttEducation, Language = c.AttLang, PaymentOrder = c.AttPlatpor, PublicRedefine = c.AttPublicRedefine, Redefine = c.AttRedefine, SomeDate = c.AttSomeDate, FieldOfKnowledge = c.AttSphereKnow, FieldOfActivity = c.AttSphereWork, GovReg = c.AttStatReg, GovRegDate = c.AttStatRegDate, WorkPlace = c.AttWorkPlace, CustomerId = c.Id, }).ToList(); return(customers, customerAttorneyInfos); }