Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
        public override int CompareTo(BaseItemWP other)
        {
            if (other is ClassWP)
            {
                return(CompareTo(other as ClassWP));
            }

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

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