Beispiel #1
0
        public async Task <PagedResultDto <NewContactListDto> > GetContacts(GetContactInput input)
        {
            var query = _NewContactRepository.GetAll().Where(c => c.CompanyId != null)
                        .WhereIf(
                !input.Filter.IsNullOrEmpty(),
                p => p.Name.Contains(input.Filter) ||
                p.CustomerTypes.Title.Contains(input.Filter)
                );
            var contact = (from a in query
                           select new NewContactListDto
            {
                Id = a.Id,
                ContactName = a.Name,
                LastName = a.LastName,
                Title = a.TitleOfCourtesies.Name,
                CompanyName = a.Companys.Name,
                CustomerTypeName = a.Companys.CustomerTypes.Title,
                NewCustomerTypeId = a.CustomerTypeId,
                ContactTypeName = a.CustomerTypes.Title
            });
            var contactCount = await contact.CountAsync();

            var contactlist = await contact
                              .OrderBy(input.Sorting)
                              .PageBy(input)
                              .ToListAsync();

            var contactlistoutput = contactlist.MapTo <List <NewContactListDto> >();

            return(new PagedResultDto <NewContactListDto>(
                       contactCount, contactlistoutput));
        }
        /// <summary>
        /// 根据查询条件获取企业联系表分页列表
        /// </summary>
        public async Task <PagedResultDto <ContactListDto> > GetPagedContactsAsync(GetContactInput input)
        {
            var query = _contactRepositoryAsNoTrack;

            //TODO:根据传入的参数添加过滤条件

            query = query.WhereIf(input.CompanyId > 0, c => c.CompanyId == input.CompanyId);

            var contactCount = await query.CountAsync();

            var contacts = await query
                           .OrderBy(input.Sorting)
                           .PageBy(input)
                           .ToListAsync();

            var contactListDtos = contacts.MapTo <List <ContactListDto> >();

            return(new PagedResultDto <ContactListDto>(
                       contactCount,
                       contactListDtos
                       ));
        }
Beispiel #3
0
        public async Task <PagedResultDto <ContactViewDto> > GetAllContacts(GetContactInput input)
        {
            var query1 = _CompanyContactRespository.GetAll();

            var query = _CompanyContactRespository.GetAll()
                        .WhereIf(
                !input.Filter.IsNullOrWhiteSpace(),
                p => p.Companies.CompanyName.Contains(input.Filter) ||
                p.Desiginations.DesiginationName.Contains(input.Filter) ||
                p.Email.Contains(input.Filter) ||
                p.Mobile_No.Contains(input.Filter) ||
                p.TitleOfCourtesies.Name.Contains(input.Filter) ||
                p.Work_No.Contains(input.Filter) ||
                p.ContactPersonName.Contains(input.Filter));

            var contactdto = from c in query
                             select new ContactViewDto
            {
                CompanyName       = c.Companies.CompanyName,
                ContactPersonName = c.TitleOfCourtesies.Name + "." + c.ContactPersonName,
                Address           = c.Address,
                Desigination      = c.DesiginationId != null ? c.Desiginations.DesiginationName : "",
                Mobile_No         = c.Mobile_No,
                Work_No           = c.Work_No,
                Description       = c.Description,
                Email             = c.Email,
                Id            = c.Id,
                CompanyId     = c.CompanyId,
                CreatorUserId = (int)(c.CreatorUserId != null ? c.CreatorUserId : 0)
            };
            var contactdtos = contactdto.OrderBy(input.Sorting).PageBy(input);


            var contactcount = await contactdto.CountAsync();

            return(new PagedResultDto <ContactViewDto>(contactcount, contactdtos.MapTo <List <ContactViewDto> >()));
        }
 public ContactDto GetContact(GetContactInput input)
 {
     return(Mapper.Map <ContactDto>(_contactRepository.FirstOrDefault(c => c.Id == input.ContactId)));
 }