public ContactListApiModel GetContacts(int accountId, int currentPage, int pageSize, string query) { var dbContacts = _accountRepository.GetContacts(accountId, currentPage, pageSize, query); var apiModel = new ContactListApiModel(); apiModel.contacts = dbContacts.contacts.Select(c => new ContactListApiModel.ContactInfo() { id = c.ID, contactName = c.Name, accountName = c.ACCOUNT.Name, email = c.Email, phone = c.Phone, owner = c.Owner.FirstName + " " + c.Owner.LastName }).ToList(); apiModel.pageInfo = dbContacts.p; return(apiModel); }
public ContactListApiModel GetContacts(int id, string query = "", int pageSize = 0, int currentPage = 1) { var dbContacts = _campaignRepository.GetContacts(id, query, pageSize, currentPage); var contacts = new ContactListApiModel(); contacts.contacts = dbContacts.contacts.Select(c => new ContactListApiModel.ContactInfo() { id = c.ID, accountName = c.ACCOUNT?.Name, contactName = c.Name, email = c.Email, owner = c.Owner?.Username, phone = c.Phone }).ToList(); contacts.pageInfo = dbContacts.p; return(contacts); }
public ContactListApiModel GetContactList(string query = "", int pageSize = 0, int currentPage = 1, List <string> sort = null) { var dbContacts = _contactRepository.GetAllContacts(query, pageSize, currentPage, sort); var apiModel = new ContactListApiModel(); string targetFolder = HttpContext.Current.Server.MapPath("~/Uploads"); apiModel.contacts = dbContacts.contacts.Select(c => new ContactListApiModel.ContactInfo() { id = c.ID, contactName = c.Name, accountName = c.ACCOUNT != null ? c.ACCOUNT.Name : "", email = c.Email, phone = c.Phone, owner = c.Owner.Username, avatar = c.Avatar != null ? $"{StaticStrings.ServerHost}avatar?fileName={c.Avatar}" : $"{StaticStrings.ServerHost}avatar?fileName=default.png" }).ToList(); apiModel.pageInfo = dbContacts.p; return(apiModel); }