Exemple #1
0
        /// <summary>
        /// Returns all the updated items
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public UpdatedItems Serialize(AccountWP account, int offset)
        {
            UpdatedItems answer = new UpdatedItems();

            foreach (var pair in _changedItems)
            {
                if (pair.Value.IsUpdated)
                {
                    //mark it sent
                    pair.Value.HasBeenSent = true;

                    //find its item
                    BaseItemWP entity = account.AccountSection.Find(pair.Key);
                    if (entity == null)
                    {
                        continue;
                    }

                    //add the serialized item to the list
                    answer.Add(entity.Serialize(offset));
                }
            }

            return(answer);
        }
        private Dictionary <string, object> getItemUpdates(AccountWP account, Guid identifier, List <ChangedProperty> changedProperties)
        {
            BaseItemWP item = account.Find(identifier);

            if (item == null)
            {
                return(null);
            }


            if (changedProperties.Any(i => i.PropertyName == BaseItemWP.PropertyNames.All))
            {
                foreach (ChangedProperty p in changedProperties)
                {
                    p.HasBeenSent = true;
                }

                return(item.SerializeToDictionary());
            }


            Dictionary <string, object> answer = new Dictionary <string, object>();

            answer["Identifier"] = identifier;
            answer["Updated"]    = item.Updated;

            foreach (ChangedProperty p in changedProperties)
            {
                answer[p.PropertyName.ToString()] = item.GetPropertyValue(p.PropertyName);
                p.HasBeenSent = true;
            }

            return(answer);
        }
Exemple #3
0
        internal override BaseItemWP FindFromSection(Guid identifier)
        {
            foreach (ClassWP c in Classes)
            {
                if (c.Identifier.Equals(identifier))
                {
                    return(c);
                }

                BaseItemWP found = c.FindFromSection(identifier);
                if (found != null)
                {
                    return(found);
                }
            }

            foreach (TaskWP t in Tasks)
            {
                if (t.Identifier.Equals(identifier))
                {
                    return(t);
                }
            }

            return(null);
        }
Exemple #4
0
        public override int CompareTo(BaseItemWP other)
        {
            if (other is ClassWP)
            {
                return(CompareTo(other as ClassWP));
            }

            return(base.CompareTo(other));
        }
Exemple #5
0
        internal override void Remove(BaseItemWP item)
        {
            //doesn't need to mark changed

            if (_semesters != null)
            {
                _semesters.Remove((SemesterWP)item);
            }
        }
Exemple #6
0
        public override int CompareTo(BaseItemWP other)
        {
            if (other is HomeworkWP)
            {
                return(CompareTo(other as HomeworkWP));
            }

            else if (other is ExamWP)
            {
                return(CompareTo(other as ExamWP));
            }

            return(base.CompareTo(other));
        }
Exemple #7
0
        public override int CompareTo(BaseItemWP other)
        {
            if (other is HomeworkWP || other is ExamWP)
            {
                //if on same day, these go earlier than tasks
                if (Date.Date == ((ExamWP)other).Date.Date)
                {
                    return(1);
                }

                //else oldest item goes first
                else
                {
                    return(Date.CompareTo(((ExamWP)other).Date));
                }
            }

            return(base.CompareTo(other));
        }
Exemple #8
0
 internal override void Add(BaseItemWP item)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 internal override void Remove(BaseItemWP item)
 {
 }
Exemple #10
0
 internal override void Add(BaseItemWP item)
 {
 }
 internal override void Remove(BaseItemWP item)
 {
     //should never be called
     throw new NotImplementedException();
 }
Exemple #12
0
 internal override void Remove(BaseItemWP item)
 {
     //teachers aren't supported yet
     throw new NotImplementedException();
 }
Exemple #13
0
 private ChangedItem grabIndex(BaseItemWP item)
 {
     return(grabIndex(item.Identifier));
 }