Пример #1
0
        public ChangesSet GetChanges(int importId, string userId)
        {
            try
            {
                var result = new ChangesSet();
                var import = _context.ImportLists.Where(x => x.UserId == userId && x.Id == importId).FirstOrDefault();
                if (import == null)
                {
                    throw new NullReferenceException("Import not found");
                }

                var previousImports = _context.ImportLists.Where(x => x.UserId == userId && x.TargetName == import.TargetName && x.Id < importId).ToArray();
                var previousImport  = _context.ImportLists.Where(x => x.UserId == userId && x.TargetName == import.TargetName && x.Id < importId).OrderByDescending(x => x.Id).FirstOrDefault();
                if (previousImport == null)
                {
                    return(result);
                }

                var initialImportFollowers  = _context.InstaUsers.Where(x => x.ImportId == importId).ToList();
                var previousImportFollowers = _context.InstaUsers.Where(x => x.ImportId == previousImport.Id).ToList();

                result.NewFollowers  = initialImportFollowers.Except(previousImportFollowers, new InstaUserComparer());
                result.PastFollowers = previousImportFollowers.Except(initialImportFollowers, new InstaUserComparer());
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// This method returns the Changes Set
        /// </summary>
        public static ChangesSet GetChangesSet(List <ExcludeInfo> originalValues, List <ExcludeInfo> currentValues)
        {
            // initial value
            ChangesSet changesSet = new ChangesSet();

            // if both lists of objects have items
            if (ListHelper.HasOneOrMoreItems(originalValues, currentValues))
            {
                // Iterate the collection of ExcludeInfo objects
                foreach (ExcludeInfo original in originalValues)
                {
                    // find the current value of this type
                    ExcludeInfo current = currentValues.FirstOrDefault(x => x.TableId == original.TableId && x.ObjectType == original.ObjectType && x.FieldId == original.FieldId);

                    // If the current object exists and the values for Exclude are different
                    if ((NullHelper.Exists(current)) && (current.Exclude != original.Exclude))
                    {
                        // Add this change
                        changesSet.Changes.Add(current);
                    }
                }
            }

            // return value
            return(changesSet);
        }
Пример #3
0
        /// <summary>
        /// This method returns the Changes Set
        /// </summary>
        public ChangesSet GetChangesSet()
        {
            // initial value
            ChangesSet changesSet = null;

            // If the DataEditorControl object exists
            if (DataEditorControl != null)
            {
                // set the return value
                changesSet = DataEditorControl.GetChangesSet();
            }

            // return value
            return(changesSet);
        }