示例#1
0
        public async Task <GetNewContacts> SearchContactInfo(EnquiryContactInput input)
        {
            var query = _NewContactInfoRepository.GetAll().Where(p => (p.InfoData == input.Email && p.NewInfoTypeId == 4) || (p.InfoData == input.MobileNo && p.NewInfoTypeId == 7)).FirstOrDefault();

            var SubListout = new GetNewContacts();

            if (query != null)
            {
                var Addinfo = _NewAddressInfoRepository.GetAll().Where(p => p.NewContacId == query.NewContacId);

                var Contactinfo = _NewContactInfoRepository.GetAll().Where(p => p.NewContacId == query.NewContacId);

                var Contact = _NewContactRepository.GetAll().Where(p => p.Id == query.NewContacId);

                if (Contact != null)
                {
                    SubListout = (from comp in Contact
                                  select new GetNewContacts
                    {
                        Id = comp.Id,
                        Name = comp.Name,
                        NewCustomerTypeId = comp.NewCustomerTypeId,
                        CompanyId = comp.NewCompanyId ?? 0,
                        CompanyName = "",
                        TitleId = comp.TitleId,
                        LastName = comp.LastName,

                        AddressInfo = (from r in Addinfo
                                       select new CreateAddressInfo
                        {
                            Id = r.Id,
                            NewCompanyId = r.NewCompanyId ?? 0,
                            NewContacId = r.NewContacId ?? 0,
                            NewInfoTypeId = r.NewInfoTypeId,
                            Address1 = r.Address1,
                            Address2 = r.Address2,
                            CityId = r.CityId,
                            CountryName = r.Citys.Country.CountryName
                        }).ToArray(),

                        Contactinfo = (from r in Contactinfo
                                       select new CreateContactInfo
                        {
                            Id = r.Id,
                            NewCompanyId = r.NewCompanyId ?? 0,
                            NewContacId = r.NewContacId ?? 0,
                            NewInfoTypeId = r.NewInfoTypeId,
                            InfoData = r.InfoData
                        }).ToArray()
                    }).FirstOrDefault();
                }
                if (SubListout.CompanyId > 0)
                {
                    var Company = (from c in _NewCompanyRepository.GetAll().Where(q => q.Id == SubListout.CompanyId) select c.Name).FirstOrDefault();
                    SubListout.CompanyName = Company;
                }
            }
            return(SubListout);
        }
示例#2
0
        public async Task <int> SearchContactInfoId(EnquiryContactInput input)
        {
            int Id    = 0;
            var query = _NewContactInfoRepository.GetAll().Where(p => (p.InfoData == input.Email && p.NewInfoTypeId == 4) || (p.InfoData == input.Telephone && p.NewInfoTypeId == 9) || (p.InfoData == input.MobileNo && p.NewInfoTypeId == 7)).FirstOrDefault();

            if (query != null)
            {
                Id = (int)query.NewContacId;
            }
            return(Id);
        }