This is a conceptualized view of a list from the service, used for databinding. As such, it provides extra properties that the underlying list does not have.
Inheritance: INotifyPropertyChanged
Example #1
0
        /// <summary>
        /// Adds a new list.  It is important to note that because there is no enforcement of
        /// data consistency in the context, the app must understand the data and enforce it.
        /// </summary>
        /// <param name="modelList">The model list to add</param>
        public void AddList(ModelList modelList)
        {
            // Extract the service entity from the model entity
            DefaultScope.List newList = modelList.List;

            // Simple argument checking
            if (null == newList)
            {
                throw new ArgumentNullException("newList");
            }

            if (newList.ID == null)
            {
                throw new ArgumentNullException("List id is null");
            }

            // Do a LINQ query to verify that the list can be added.  Current constraints
            // are unique id and unique name.
            DefaultScope.List existingList = (from s in context.ListCollection
                                              where s.ID == newList.ID || s.Name == newList.Name
                                              select s).FirstOrDefault();

            if (existingList != default(List))
            {
                throw new ArgumentException("List with the same id already exists");
            }

            // Add the list to the context.
            context.AddList(newList);
        }
        /// <summary>
        /// Constructor which takes the parent list for a new item
        /// </summary>
        /// <param name="list">Parent list for an item</param>
        public ModifyItemChildWindow(ModelList list)
        {
            InitializeComponent();

            item = ContextModel.Instance.GetNewItem(list);
            NewItem = true;

            this.Loaded += new RoutedEventHandler(ItemModifyChildWindow_Loaded);
        }
        public ModifyListChildWindow(DefaultScope.List scopeList)
        {
            InitializeComponent();

            list = ContextModel.Instance.GetList(scopeList);
            NewList = true;

            this.Loaded += new RoutedEventHandler(NewListChildWindow_Loaded);
        }
Example #4
0
        /// <summary>
        /// Gets a new model item for creating an item.  Takes the
        /// parent list
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public ModelItem GetNewItem(ModelList list)
        {
            // This method requires the parent list and the user id
            // to ensure that referential integrity is maintained
            Item item = new Item()
            {
                ID     = Guid.NewGuid(),
                UserID = UserID,
                ListID = list.List.ID
            };

            return(new ModelItem(item, context));
        }
Example #5
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            Model.ModelItem srcItem = value as Model.ModelItem;

            if (srcItem != null)
            {
                return(srcItem.Item);
            }

            Model.ModelList srcList = value as Model.ModelList;

            if (srcList != null)
            {
                return(srcList.List);
            }

            return(null);
        }
Example #6
0
        /// <summary>
        /// Gets a new model item for creating an item.  Takes the
        /// parent list
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public ModelItem GetNewItem(ModelList list)
        {
            // This method requires the parent list and the user id
            // to ensure that referential integrity is maintained
            Item item = new Item()
            {
                ID = Guid.NewGuid(),
                UserID = UserID,
                ListID = list.List.ID
            };

            return new ModelItem(item, context);
        }
Example #7
0
        /// <summary>
        /// Adds a new list.  It is important to note that because there is no enforcement of
        /// data consistency in the context, the app must understand the data and enforce it.
        /// </summary>
        /// <param name="modelList">The model list to add</param>
        public void AddList(ModelList modelList)
        {
            // Extract the service entity from the model entity
            DefaultScope.List newList = modelList.List;

            // Simple argument checking
            if (null == newList)
            {
                throw new ArgumentNullException("newList");
            }

            if (newList.ID == null)
            {
                throw new ArgumentNullException("List id is null");
            }

            // Do a LINQ query to verify that the list can be added.  Current constraints
            // are unique id and unique name.
            DefaultScope.List existingList = (from s in context.ListCollection
                                              where s.ID == newList.ID || s.Name == newList.Name
                                              select s).FirstOrDefault();

            if (existingList != default(List))
            {
                throw new ArgumentException("List with the same id already exists");
            }

            // Add the list to the context.
            context.AddList(newList);
        }