public async Task <BaseResponseModel> AddCustomerContact(int customerId, string address, string phone) { var customer = await _customerRepository.Table.AsNoTracking() .FirstOrDefaultAsync(x => x.Id == customerId && x.IsActive); if (customer == null) { return(new BaseResponseModel(404, message: "Customer Is Not Found!!")); } var contact = new Data.Entities.Contact { CustomerId = customerId, Address = address, Phone = phone, CreatedAt = DateTime.Now, IsActive = true, CreatedBy = 1 }; await _contactRepository.InsertAsync(contact); await _contactRepository.SaveAllAsync(); var context = new CustomerContext { CustomerId = customerId, Address = address, Phone = phone, CreatedAt = customer.CreatedAt, Email = customer.Email }; return(new BaseResponseModel(200, context, "Contact Added!!")); }
public static Domain.Contact Map(Data.Entities.Contact deContact) => new Domain.Contact { Id = deContact.Id, FirstName = deContact.FirstName, LastName = deContact.LastName, MiddleName = deContact.MiddleName, Mobile = deContact.Mobile, Email = deContact.Email, HomePhone = deContact.HomePhone, WorkPhone = deContact.WorkPhone, Created = deContact.Created, Modified = deContact.Modified };
protected void loadData(string keyword) { int clientID = Core.SessionHelper.getClientId(); IQueryable <CRM.Data.Entities.Contact> contacts = null; if (keyword == null) { contacts = ContactManager.GetAll(clientID); } else { contacts = ContactManager.Search(keyword, clientID); } List <CRM.Data.Entities.Contact> contactList = contacts.ToList(); int userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string email = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(email, password); service.Url = new Uri(url); ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts); int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50; ItemView view = new ItemView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName); FindItemsResults <Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view); foreach (Item item in contactItems) { if (item is Microsoft.Exchange.WebServices.Data.Contact) { item.Load(); Microsoft.Exchange.WebServices.Data.Contact contact = item as Microsoft.Exchange.WebServices.Data.Contact; CRM.Data.Entities.Contact newContact = new Data.Entities.Contact(); newContact.FirstName = contact.GivenName; newContact.LastName = contact.Surname; newContact.Email = contact.EmailAddresses[0].Address; newContact.DepartmentName = "Outlook"; bool exist = false; if (keyword == null || keyword[0] == newContact.Email[0]) { foreach (var con in contactList) { if (con.Email == newContact.Email) { exist = true; } } } if (!exist) { contactList.Add(newContact); } } } } catch (Exception ex) { } gvContact.DataSource = contactList; gvContact.DataBind(); }
protected void loadData(string keyword) { int clientID = Core.SessionHelper.getClientId(); IQueryable<CRM.Data.Entities.Contact> contacts = null; if (keyword == null) { contacts = ContactManager.GetAll(clientID); } else { contacts = ContactManager.Search(keyword, clientID); } List<CRM.Data.Entities.Contact> contactList = contacts.ToList(); int userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string email = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(email, password); service.Url = new Uri(url); ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts); int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50; ItemView view = new ItemView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName); FindItemsResults<Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view); foreach (Item item in contactItems) { if (item is Microsoft.Exchange.WebServices.Data.Contact) { item.Load(); Microsoft.Exchange.WebServices.Data.Contact contact = item as Microsoft.Exchange.WebServices.Data.Contact; CRM.Data.Entities.Contact newContact = new Data.Entities.Contact(); newContact.FirstName = contact.GivenName; newContact.LastName = contact.Surname; newContact.Email = contact.EmailAddresses[0].Address; newContact.DepartmentName = "Outlook"; bool exist = false; if (keyword == null || keyword[0] == newContact.Email[0]) foreach (var con in contactList) { if (con.Email == newContact.Email) exist = true; } if (!exist) contactList.Add(newContact); } } } catch (Exception ex) { } gvContact.DataSource = contactList; gvContact.DataBind(); }