Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 public async Task <List <ContactInfo> > GetAllByContactAsync(Guid contactId, ContactInfoType type)
 {
     return(await _dataContext.ContactInfos
            .Where(x =>
                   x.ContactId == contactId &&
                   x.Type == type)
            .ToListAsync());
 }
Exemplo n.º 3
0
 public static Type GetCategory(ContactInfoType infoType)
 {
     switch (infoType)
     {
         case ContactInfoType.Phone:
             return typeof(PhoneCategory);
         case ContactInfoType.Address:
             return typeof(AddressCategory);
         default:
             return typeof(ContactInfoBaseCategory);
     }
 }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
 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;
     }
 }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        public static Type GetCategory(ContactInfoType infoType)
        {
            switch (infoType)
            {
            case ContactInfoType.Phone:
                return(typeof(PhoneCategory));

            case ContactInfoType.Address:
                return(typeof(AddressCategory));

            default:
                return(typeof(ContactInfoBaseCategory));
            }
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        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());
        }
Exemplo n.º 12
0
        /// <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());
        }
Exemplo n.º 14
0
        /// <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;
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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;
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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;

        }
Exemplo n.º 19
0
        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);
 }
Exemplo n.º 21
0
        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;
        }
Exemplo n.º 22
0
        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;
        }
Exemplo n.º 23
0
 public List<String> GetListData(int contactID, ContactInfoType infoType)
 {
     return GetList(contactID, infoType, null, null).ConvertAll(item => item.Data);
 }
Exemplo n.º 24
0
 partial void UpdateContactInfoType(ContactInfoType instance);
Exemplo n.º 25
0
        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;

        }
Exemplo n.º 26
0
 public List <String> GetListData(int contactID, ContactInfoType infoType)
 {
     return(GetList(contactID, infoType, null, null).ConvertAll(item => item.Data));
 }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
        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;
        }
Exemplo n.º 29
0
 public async Task <IActionResult> GetAllByContactAndType([FromRoute] Guid contactId, ContactInfoType type)
 {
     return(Ok(await _contactInfoService.GetAllByContactAsync(contactId, type)));
 }
Exemplo n.º 30
0
 public IEnumerable <string> GetContactInfoCategory(ContactInfoType infoType)
 {
     return(Enum.GetNames(ContactInfo.GetCategory(infoType)));
 }
Exemplo n.º 31
0
 public IEnumerable<String> GetContactInfo(int contactid, ContactInfoType infoType)
 {
     return DaoFactory.GetContactInfoDao().GetListData(contactid, infoType);
 }
Exemplo n.º 32
0
 public IEnumerable<String> GetContactInfoCategory(ContactInfoType infoType)
 {
     return Enum.GetNames(ContactInfo.GetCategory(infoType)).ToItemList();
 }
Exemplo n.º 33
0
 public IEnumerable <String> GetContactInfo(int contactid, ContactInfoType infoType)
 {
     return(DaoFactory.GetContactInfoDao().GetListData(contactid, infoType));
 }
Exemplo n.º 34
0
 partial void InsertContactInfoType(ContactInfoType instance);
Exemplo n.º 35
0
        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));
        }
Exemplo n.º 36
0
        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();
        }
Exemplo n.º 38
0
 public IEnumerable <String> GetContactInfoCategory(ContactInfoType infoType)
 {
     return(Enum.GetNames(ContactInfo.GetCategory(infoType)).ToItemList());
 }
Exemplo n.º 39
0
        public IEnumerable <MailContactData> GetContactsByContactInfo(ContactInfoType infoType, String data, bool?isPrimary)
        {
            var contacts = MailBoxManager.GetContactsByContactInfo(TenantId, Username, infoType, data, isPrimary);

            return(contacts.ToContactData());
        }
Exemplo n.º 40
0
        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);
        }
Exemplo n.º 41
0
        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();
 }
Exemplo n.º 43
0
 partial void DeleteContactInfoType(ContactInfoType instance);
Exemplo n.º 44
0
        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);
        }
Exemplo n.º 45
0
 public static ContactInfoTypeReference GetReference(ContactInfoType entryType)
 {
     return(References.FirstOrDefault(s => s.EntryType == entryType));
 }
Exemplo n.º 46
0
        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;
        }