public IEnumerable <MailContactData> GetContactsByContactInfo(ContactInfoType infoType, String data, bool?isPrimary) { var exp = new FullFilterContactsExp(TenantId, Username, data, infoType: infoType, isPrimary: isPrimary); var contacts = MailEngineFactory.ContactEngine.GetContactCards(exp); return(contacts.ToMailContactDataList()); }
public async Task <List <ContactInfo> > GetAllByContactAsync(Guid contactId, ContactInfoType type) { return(await _dataContext.ContactInfos .Where(x => x.ContactId == contactId && x.Type == type) .ToListAsync()); }
public static Type GetCategory(ContactInfoType infoType) { switch (infoType) { case ContactInfoType.Phone: return typeof(PhoneCategory); case ContactInfoType.Address: return typeof(AddressCategory); default: return typeof(ContactInfoBaseCategory); } }
public static int GetDefaultCategory(ContactInfoType infoTypeEnum) { switch (infoTypeEnum) { case ContactInfoType.Phone: return (int)PhoneCategory.Work; case ContactInfoType.Address: return (int)AddressCategory.Work; default: return (int)ContactInfoBaseCategory.Work; } }
public async Task <IList <ContactInfo> > Select(Guid personID, ContactInfoType type) { var param = new DynamicParameters(); param.Add("@PersonID", personID); param.Add("@Type", type); return((await SqlMapper.QueryAsync <ContactInfo>(_unitOfWork.Connection, "SelectContactInfo", param, commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).ToList()); }
public void InsertOrUpdate(ContactInfoType contactinfotype) { if (contactinfotype.Id == default(int)) { // New entity context.ContactInfoTypes.Add(contactinfotype); } else { // Existing entity context.Entry(contactinfotype).State = EntityState.Modified; } }
public static int GetDefaultCategory(ContactInfoType infoTypeEnum) { switch (infoTypeEnum) { case ContactInfoType.Phone: return((int)PhoneCategory.Work); case ContactInfoType.Address: return((int)AddressCategory.Work); default: return((int)ContactInfoBaseCategory.Work); } }
public static Type GetCategory(ContactInfoType infoType) { switch (infoType) { case ContactInfoType.Phone: return(typeof(PhoneCategory)); case ContactInfoType.Address: return(typeof(AddressCategory)); default: return(typeof(ContactInfoBaseCategory)); } }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, string data, bool isPrimary, string category) { if (string.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contact = DaoFactory.GetContactDao().GetByID(contactid); if (contact == null || !CRMSecurity.CanEdit(contact)) { throw new ItemNotFoundException(); } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(_context, messageAction, contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
public IEnumerable <string> GetContactInfo(int contactid, ContactInfoType infoType) { if (contactid <= 0) { throw new ArgumentException(); } var contact = DaoFactory.ContactDao.GetByID(contactid); if (contact == null || !CRMSecurity.CanAccessTo(contact)) { throw new ItemNotFoundException(); } return(DaoFactory.ContactInfoDao.GetListData(contactid, infoType)); }
private String PrepareteDataToView(ContactInfoType contactInfoType, String data) { if (contactInfoType != ContactInfoType.Address) { return(data); } var addressParts = JObject.Parse(data); var address = new StringBuilder(); foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) { address.Append(addressParts[addressPartEnum.ToString().ToLower()] + " "); } return(address.ToString()); }
/// <summary> /// Creates a new instance of a ContactInfo object, and initializes it with the specified properties. /// </summary> /// <param name="participant"></param> /// <param name="name"></param> /// <param name="type"></param> /// <param name="category"></param> /// <param name="value"></param> public ContactInfo(Participant participant, string name, ContactInfoType type, ContactInfoCategory category, string value) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } if (String.IsNullOrWhiteSpace(value)) { throw new ArgumentNullException(nameof(value)); } this.Participants.Add(new ParticipantContactInfo(participant, this)); this.Name = name; this.Type = type; this.Category = category; this.Value = value; }
private String PrepareteDataToView(ContactInfoType contactInfoType, String data) { if (contactInfoType != ContactInfoType.Address) { return(data); } var addressParts = JsonDocument.Parse(data).RootElement; var address = new StringBuilder(); foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) { address.Append(addressParts.GetProperty(addressPartEnum.ToString().ToLower()).GetString() + " "); } return(address.ToString()); }
/// <summary> /// Creates a new instance of a ContactInfo object, and initializes it with the specified properties. /// </summary> /// <param name="user"></param> /// <param name="name"></param> /// <param name="type"></param> /// <param name="category"></param> /// <param name="value"></param> public ContactInfo(User user, string name, ContactInfoType type, ContactInfoCategory category, string value) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } if (String.IsNullOrWhiteSpace(value)) { throw new ArgumentNullException(nameof(value)); } this.Users.Add(new UserContactInfo(user, this)); this.Name = name; this.Type = type; this.Category = category; this.Value = value; }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, String data, bool isPrimary, String category ) { if (String.IsNullOrEmpty(data) || contactid == 0) { throw new ArgumentException(); } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var contact = DaoFactory.GetContactDao().GetByID(contactInfo.ContactID); var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
public ContactInfoVM(ContactInfoType contactInfoType, EntityCollection<ContactInfo> contactInfoSet) { //Update the ContactInfoDataService whenever the LocationsContactInfoDataService or the PartyContactInfoDataService changes Manager.Data.DomainContext.FromAnyPropertyChanged() .Where(pce => pce.PropertyName == "LocationsContactInfoDataService" || pce.PropertyName == "PartyContactInfoDataService" || pce.PropertyName == "ClientsContactInfoDataService") .AsGeneric().AndNow().SubscribeOnDispatcher().Subscribe(_ => { if (Manager.Context.OwnerAccount != null) switch (contactInfoType) { case ContactInfoType.Clients: ContactInfoDataService = Manager.Data.DomainContext.ClientsContactInfoDataService(Manager.Context.OwnerAccount.Id); break; case ContactInfoType.Locations: ContactInfoDataService = Manager.Data.DomainContext.LocationsContactInfoDataService(Manager.Context.OwnerAccount.Id); break; case ContactInfoType.OwnedParties: ContactInfoDataService = Manager.Data.DomainContext.PartyContactInfoDataService(Manager.Context.OwnerAccount.Id); break; } }); ContactInfoSet = contactInfoSet; }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, String data, bool isPrimary, String category ) { if (String.IsNullOrEmpty(data) || contactid == 0) { throw new ArgumentException(); } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
public ContactInfoWrapper UpdateContactInfo( int id, int contactid, ContactInfoType? infoType, String data, bool? isPrimary, String category) { if (id == 0 || String.IsNullOrEmpty(data) || contactid <= 0) throw new ArgumentException(); var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!String.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) contactInfo.Category = (int)Enum.ToObject(categoryType, category); contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) contactInfo.IsPrimary = isPrimary.Value; contactInfo.Data = data; DaoFactory.GetContactInfoDao().Update(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var contact = DaoFactory.GetContactDao().GetByID(contactInfo.ContactID); var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return contactInfoWrapper; }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, String data, bool isPrimary, String category ) { if (String.IsNullOrEmpty(data) || contactid == 0) throw new ArgumentException(); var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) throw new ArgumentException(); var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var contact = DaoFactory.GetContactDao().GetByID(contactInfo.ContactID); var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return contactInfoWrapper; }
public AddContactInfoWindow(List <ContactInfoType> lst, ContactInfoType typ, string val) { InitializeComponent(); DataContext = new AddContactInfoViewModel(lst, typ, val); }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, String data, bool isPrimary, String category ) { if (String.IsNullOrEmpty(data) || contactid == 0) throw new ArgumentException(); var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) throw new ArgumentException(); var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return contactInfoWrapper; }
public List<int> GetContactIDsByContactInfo(ContactInfoType infoType, String data, int? category, bool? isPrimary) { var ids = new List<int>(); var q = new SqlQuery("crm_contact_info") .Select("contact_id") .Where(Exp.Eq("type", (int)infoType)); if (!string.IsNullOrWhiteSpace(data)) { q = q.Where(Exp.Like("data", data, SqlLike.AnyWhere)); } if (category.HasValue) { q = q.Where("category", category.Value); } if (isPrimary.HasValue) { q = q.Where("is_primary", isPrimary.Value); } using (var db = GetDb()) { ids = db.ExecuteList(q).ConvertAll(row => (int)row[0]); } return ids; }
public List<String> GetListData(int contactID, ContactInfoType infoType) { return GetList(contactID, infoType, null, null).ConvertAll(item => item.Data); }
partial void UpdateContactInfoType(ContactInfoType instance);
public ContactInfoWrapper UpdateContactInfo( int id, int contactid, ContactInfoType? infoType, String data, bool? isPrimary, String category) { if (id == 0 || String.IsNullOrEmpty(data) || contactid <= 0) throw new ArgumentException(); var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!String.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) contactInfo.Category = (int)Enum.ToObject(categoryType, category); contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) contactInfo.IsPrimary = isPrimary.Value; contactInfo.Data = data; DaoFactory.GetContactInfoDao().Update(contactInfo); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return contactInfoWrapper; }
public List <String> GetListData(int contactID, ContactInfoType infoType) { return(GetList(contactID, infoType, null, null).ConvertAll(item => item.Data)); }
public ContactInfoWrapper UpdateContactInfo(int id, int contactid, ContactInfoType? infoType, string data, bool? isPrimary, string category) { if (id <= 0 || string.IsNullOrEmpty(data) || contactid <= 0) throw new ArgumentException(); var contact = DaoFactory.GetContactDao().GetByID(contactid); if (contact == null || !CRMSecurity.CanEdit(contact)) throw new ItemNotFoundException(); var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!string.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) { contactInfo.Category = (int)Enum.Parse(categoryType, category); } contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) { contactInfo.IsPrimary = isPrimary.Value; } contactInfo.Data = data; if (contactInfo.InfoType == ContactInfoType.Address) { Address res; if (!Address.TryParse(contactInfo, out res)) throw new ArgumentException(); } DaoFactory.GetContactInfoDao().Update(contactInfo); var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(Request, messageAction, contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return contactInfoWrapper; }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, string data, bool isPrimary, string category) { if (string.IsNullOrEmpty(data) || contactid <= 0) throw new ArgumentException(); var contact = DaoFactory.GetContactDao().GetByID(contactid); if (contact == null) throw new ItemNotFoundException(); if (infoType == ContactInfoType.Twitter) { if (!CRMSecurity.CanAccessTo(contact)) throw new ItemNotFoundException(); } else { if (!CRMSecurity.CanEdit(contact)) throw new ItemNotFoundException(); } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) throw new ArgumentException(); var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; if (contactInfo.InfoType == ContactInfoType.Address) { Address res; if (!Address.TryParse(contactInfo, out res)) throw new ArgumentException(); } var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(Request, messageAction, contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return contactInfoWrapper; }
public async Task <IActionResult> GetAllByContactAndType([FromRoute] Guid contactId, ContactInfoType type) { return(Ok(await _contactInfoService.GetAllByContactAsync(contactId, type))); }
public IEnumerable <string> GetContactInfoCategory(ContactInfoType infoType) { return(Enum.GetNames(ContactInfo.GetCategory(infoType))); }
public IEnumerable<String> GetContactInfo(int contactid, ContactInfoType infoType) { return DaoFactory.GetContactInfoDao().GetListData(contactid, infoType); }
public IEnumerable<String> GetContactInfoCategory(ContactInfoType infoType) { return Enum.GetNames(ContactInfo.GetCategory(infoType)).ToItemList(); }
public IEnumerable <String> GetContactInfo(int contactid, ContactInfoType infoType) { return(DaoFactory.GetContactInfoDao().GetListData(contactid, infoType)); }
partial void InsertContactInfoType(ContactInfoType instance);
private int SaveContactInfo(DbManager db, int tenant, string user, int contactId, string data, ContactInfoType infoType, bool isPrimary) { var query = new SqlInsert(ContactInfoTable.Name) .InColumnValue(ContactInfoTable.Columns.Tenant, tenant) .InColumnValue(ContactInfoTable.Columns.User, user) .InColumnValue(ContactInfoTable.Columns.ContactId, contactId) .InColumnValue(ContactInfoTable.Columns.Data, data) .InColumnValue(ContactInfoTable.Columns.Type, (int)infoType) .InColumnValue(ContactInfoTable.Columns.IsPrimary, isPrimary); return(db.ExecuteScalar <int>(query)); }
public virtual List<ContactInfo> GetList(int contactID, ContactInfoType? infoType, int? categoryID, bool? isPrimary) { SqlQuery sqlQuery = GetSqlQuery(null); if (contactID > 0) sqlQuery.Where(Exp.Eq("contact_id", contactID)); if (infoType.HasValue) sqlQuery.Where(Exp.Eq("type", infoType.Value)); if (categoryID.HasValue) sqlQuery.Where(Exp.Eq("category", categoryID.Value)); if (isPrimary.HasValue) sqlQuery.Where(Exp.Eq("is_primary", isPrimary.Value)); sqlQuery.OrderBy("type", true); // sqlQuery.OrderBy("category", true); // sqlQuery.OrderBy("is_primary", true); using (var db = GetDb()) { return db.ExecuteList(sqlQuery).ConvertAll(row => ToContactInfo(row)); } }
private String PrepareteDataToView(ContactInfoType contactInfoType, String data) { if (contactInfoType != ContactInfoType.Address) return data; var addressParts = JObject.Parse(data); var address = new StringBuilder(); foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) address.Append(addressParts[addressPartEnum.ToString().ToLower()] + " "); return address.ToString(); }
public IEnumerable <String> GetContactInfoCategory(ContactInfoType infoType) { return(Enum.GetNames(ContactInfo.GetCategory(infoType)).ToItemList()); }
public IEnumerable <MailContactData> GetContactsByContactInfo(ContactInfoType infoType, String data, bool?isPrimary) { var contacts = MailBoxManager.GetContactsByContactInfo(TenantId, Username, infoType, data, isPrimary); return(contacts.ToContactData()); }
public List <ContactCardDto> GetContactsByContactInfo(int tenant, string user, ContactInfoType infoType, String data, bool?isPrimary) { if (data == null) { throw new ArgumentNullException("data"); } List <ContactCardDto> result; const string mail_contacts = "mc"; const string contact_info = "ci"; using (var db = GetDb()) { var queryContacts = new SqlQuery(ContactsTable.Name.Alias(mail_contacts)) .InnerJoin(ContactInfoTable.Name.Alias(contact_info), Exp.EqColumns(ContactsTable.Columns.Id.Prefix(mail_contacts), ContactInfoTable.Columns.ContactId.Prefix(contact_info))) .Select( ContactsTable.Columns.Id.Prefix(mail_contacts), ContactsTable.Columns.User.Prefix(mail_contacts), ContactsTable.Columns.Tenant.Prefix(mail_contacts), ContactsTable.Columns.ContactName.Prefix(mail_contacts), ContactsTable.Columns.Description.Prefix(mail_contacts), ContactsTable.Columns.Type.Prefix(mail_contacts), ContactsTable.Columns.HasPhoto.Prefix(mail_contacts), ContactInfoTable.Columns.Id.Prefix(contact_info), ContactInfoTable.Columns.Tenant.Prefix(contact_info), ContactInfoTable.Columns.User.Prefix(contact_info), ContactInfoTable.Columns.ContactId.Prefix(contact_info), ContactInfoTable.Columns.Data.Prefix(contact_info), ContactInfoTable.Columns.Type.Prefix(contact_info), ContactInfoTable.Columns.IsPrimary.Prefix(contact_info)) .Where(ContactInfoTable.Columns.Tenant.Prefix(contact_info), tenant) .Where(ContactInfoTable.Columns.User.Prefix(contact_info), user) .Where(ContactInfoTable.Columns.Data.Prefix(contact_info), data) .Where(ContactInfoTable.Columns.Type.Prefix(contact_info), (int)infoType); if (isPrimary.HasValue) { queryContacts = queryContacts.Where(ContactInfoTable.Columns.IsPrimary.Prefix(contact_info), isPrimary.Value); } result = db.ExecuteList(queryContacts).ToContactCardDto(); } return(result); }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, string data, bool isPrimary, string category) { if (string.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contact = DaoFactory.ContactDao.GetByID(contactid); if (contact == null) { throw new ItemNotFoundException(); } if (infoType == ContactInfoType.Twitter) { if (!CRMSecurity.CanAccessTo(contact)) { throw new ItemNotFoundException(); } } else { if (!CRMSecurity.CanEdit(contact)) { throw new ItemNotFoundException(); } } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; if (contactInfo.InfoType == ContactInfoType.Address) { Address res; if (!Address.TryParse(contactInfo, out res)) { throw new ArgumentException(); } } var contactInfoID = DaoFactory.ContactInfoDao.Save(contactInfo); var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(Request, messageAction, MessageTarget.Create(contact.ID), contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
public AffiliationInfoTypePartnerInfo() { this._description = new ParagraphType(); this._contact = new ContactInfoType(); }
partial void DeleteContactInfoType(ContactInfoType instance);
public IEnumerable<string> GetContactInfo(int contactid, ContactInfoType infoType) { if (contactid <= 0) throw new ArgumentException(); var contact = DaoFactory.GetContactDao().GetByID(contactid); if (contact == null || !CRMSecurity.CanAccessTo(contact)) throw new ItemNotFoundException(); return DaoFactory.GetContactInfoDao().GetListData(contactid, infoType); }
public static ContactInfoTypeReference GetReference(ContactInfoType entryType) { return(References.FirstOrDefault(s => s.EntryType == entryType)); }
public IEnumerable<ContactWrapper> GetContactsByContactInfo(ContactInfoType? infoType, String data, int? category, bool? isPrimary) { if (!infoType.HasValue) throw new ArgumentException(); var ids = DaoFactory.GetContactDao().GetContactIDsByContactInfo(infoType.Value, data, category, isPrimary); var result = DaoFactory.GetContactDao().GetContacts(ids.ToArray()).ConvertAll(ToContactWrapper); return result; }
public ContactInfoWrapper UpdateContactInfo(int id, int contactid, ContactInfoType? infoType, string data, bool? isPrimary, string category) { if (id <= 0 || string.IsNullOrEmpty(data) || contactid <= 0) throw new ArgumentException(); var contact = DaoFactory.GetContactDao().GetByID(contactid); if (contact == null || !CRMSecurity.CanEdit(contact)) throw new ItemNotFoundException(); var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!string.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) { contactInfo.Category = (int)Enum.Parse(categoryType, category); } contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) { contactInfo.IsPrimary = isPrimary.Value; } contactInfo.Data = data; DaoFactory.GetContactInfoDao().Update(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] {contactInfo.Data}; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(_context, messageAction, contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return contactInfoWrapper; }