Example #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);
        }
Example #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);
        }
Example #4
0
        public override int CompareTo(BaseItemWP other)
        {
            if (other is ClassWP)
            {
                return(CompareTo(other as ClassWP));
            }

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

            if (_semesters != null)
            {
                _semesters.Remove((SemesterWP)item);
            }
        }
Example #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));
        }
Example #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));
        }
Example #8
0
 internal override void Add(BaseItemWP item)
 {
     throw new NotImplementedException();
 }
Example #9
0
 internal override void Remove(BaseItemWP item)
 {
 }
Example #10
0
 internal override void Add(BaseItemWP item)
 {
 }
 internal override void Remove(BaseItemWP item)
 {
     //should never be called
     throw new NotImplementedException();
 }
Example #12
0
 internal override void Remove(BaseItemWP item)
 {
     //teachers aren't supported yet
     throw new NotImplementedException();
 }
Example #13
0
 private ChangedItem grabIndex(BaseItemWP item)
 {
     return(grabIndex(item.Identifier));
 }