Example #1
0
        public void deleteItem()
        {
            Console.WriteLine("Input the item number to REMOVE:");
            KBItem item = this.getItem();

            if (item != null)
            {
                items = items.Where(x => x.Id != item.Id).ToArray();
            }
        }
Example #2
0
        public void editItem()
        {
            Console.WriteLine("Input the item number to edit:");
            KBItem item = this.getItem();

            if (item != null)
            {
                foreach (var localItem in items)
                {
                    if (localItem.Id == item.Id)
                    {
                        Console.WriteLine("Please set the new description: ");
                        localItem.Description = Console.ReadLine();
                    }
                }
            }
        }
Example #3
0
        public KBItem getItem()
        {
            int item2Edit;

            int.TryParse(Console.ReadLine(), out item2Edit);

            KBItem item = null;

            if (items != null &&
                items.Count() > 0 &&
                items.Where(x => x.Id == item2Edit).Any())
            {
                item = items.Where(x => x.Id == item2Edit).First();
            }

            return(item);
        }
Example #4
0
        public int CompareTo(object obj)
        {
            KBItem item2 = obj as KBItem;

            if (this.Id > item2.Id)
            {
                return(1);
            }
            else if (this.Id < item2.Id)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Example #5
0
        public void moveItem()
        {
            Console.WriteLine("Input the item number to move:");
            KBItem item = this.getItem();

            if (item != null)
            {
                int newStatus;

                do
                {
                    Console.WriteLine("Select the new status\t(1) TODO, (2) IN PROCESS, (3) DONE");
                    int.TryParse(Console.ReadLine(), out newStatus);
                }while (newStatus < 0 || newStatus > 3); // status should be 1, 2 or 3

                foreach (var localItem in items)
                {
                    if (localItem.Id == item.Id)
                    {
                        localItem.Status = newStatus;
                    }
                }
            }
        }