コード例 #1
0
        private bool CanUpdateContactTitle(User contact, string title)
        {
            bool canUpdate        = false;
            bool wasUpdatedByUser = false;

            ActionLogs actionLogs = new ActionLogs(LoginUser);

            actionLogs.LoadByUserID(contact.UserID);

            ActionLog lastActionLog = actionLogs.OrderByDescending(p => p.DateCreated)
                                      .Where(p => p.RefType == ReferenceType.Users &&
                                             p.Description.ToLower().Contains("set contact title"))
                                      .FirstOrDefault();

            //If the title has been updated before, we need to check if the user did it. If not then we can update.
            if (lastActionLog != null)
            {
                wasUpdatedByUser = lastActionLog.ModifierID > 0;

                if (!wasUpdatedByUser)
                {
                    canUpdate = contact.Title != title;
                }
            }
            else if (string.IsNullOrEmpty(contact.Title))
            {
                //The title has never changed. Update it if empty
                canUpdate = true;
            }

            return(canUpdate);
        }
コード例 #2
0
        private bool CanUpdateCompanyBio(Organization organization, string bio)
        {
            bool canUpdate        = false;
            bool wasUpdatedByUser = false;

            ActionLogs actionLogs = new ActionLogs(LoginUser);

            actionLogs.LoadByOrganizationID(organization.OrganizationID);

            ActionLog lastActionLog = actionLogs.OrderByDescending(p => p.DateCreated)
                                      .Where(p => p.RefType == ReferenceType.Organizations &&
                                             (p.Description.ToLower().Contains("changed description")) ||
                                             p.Description.ToLower().Contains("set company description"))
                                      .FirstOrDefault();

            //If the description has been updated before, we need to check if the user did it. If not then we can update.
            if (lastActionLog != null)
            {
                wasUpdatedByUser = lastActionLog.ModifierID > 0;

                if (!wasUpdatedByUser)
                {
                    canUpdate = organization.Description != bio;
                }
            }
            else if (string.IsNullOrEmpty(organization.Description))
            {
                //The description has never changed. Update it if empty
                canUpdate = true;
            }

            return(canUpdate);
        }