Beispiel #1
0
        public void MoveDown(DataListRelationship item)
        {
            var otherItems = this.Relationships.Where(i => i.Order > item.Order).ToList();

            if (!otherItems.Any())
            {
                return;
            }

            var MinBigger = otherItems.Min(i => i.Order);

            if (MinBigger > 0)
            {
                var bigger = otherItems.Where(i => i.Order == MinBigger).First();
                bigger.Order = item.Order;
                item.Order   = MinBigger;
            }
        }
Beispiel #2
0
        //public void AddRelationship(DataListRelationship relationship)
        //{
        //    if (AllRelationships.Count() == MAX_RELATIONSHIPS)
        //        throw new ValidationException(string.Format("A new relationship cannot be added to {0}!", Name));

        //    if (Relationship1Id == null) Relationship1 = relationship;
        //    else if (Relationship2Id == null) Relationship2 = relationship;
        //    else if (Relationship3Id == null) Relationship3 = relationship;
        //    else if (Relationship4Id == null) Relationship4 = relationship;
        //    else if (Relationship5Id == null) Relationship5 = relationship;
        //    else if (Relationship6Id == null) Relationship6 = relationship;
        //    else if (Relationship7Id == null) Relationship7 = relationship;
        //    else if (Relationship8Id == null) Relationship8 = relationship;
        //    else if (Relationship9Id == null) Relationship9 = relationship;
        //}

        //public void RemoveRelationship(DataListRelationship relationship)
        //{
        //    if (Relationship1Id == relationship.Id) { Relationship1Id = null; this.AllItems.ToList().ForEach(i => i.Attr1Id = null); }
        //    else if (Relationship2Id == relationship.Id) { Relationship2Id = null; this.AllItems.ToList().ForEach(i => i.Attr2Id = null); }
        //    else if (Relationship3Id == relationship.Id) { Relationship3Id = null; this.AllItems.ToList().ForEach(i => i.Attr3Id = null); }
        //    else if (Relationship4Id == relationship.Id) { Relationship4Id = null; this.AllItems.ToList().ForEach(i => i.Attr4Id = null); }
        //    else if (Relationship5Id == relationship.Id) { Relationship5Id = null; this.AllItems.ToList().ForEach(i => i.Attr5Id = null); }
        //    else if (Relationship6Id == relationship.Id) { Relationship6Id = null; this.AllItems.ToList().ForEach(i => i.Attr6Id = null); }
        //    else if (Relationship7Id == relationship.Id) { Relationship7Id = null; this.AllItems.ToList().ForEach(i => i.Attr7Id = null); }
        //    else if (Relationship8Id == relationship.Id) { Relationship8Id = null; this.AllItems.ToList().ForEach(i => i.Attr8Id = null); }
        //    else if (Relationship9Id == relationship.Id) { Relationship9Id = null; this.AllItems.ToList().ForEach(i => i.Attr9Id = null); }
        //}

        public void MoveUp(DataListRelationship item)
        {
            var otherItems = this.Relationships.Where(i => i.Order < item.Order).ToList();

            if (!otherItems.Any())
            {
                return;
            }

            var MaxSmaller = otherItems.Max(i => i.Order);

            if (MaxSmaller > 0)
            {
                var smaller = otherItems.Where(i => i.Order == MaxSmaller).Last();
                smaller.Order = item.Order;
                item.Order    = MaxSmaller;
            }
        }