Beispiel #1
0
        public static WorkItem Create(int id)
        {
            var workItem = new WorkItem()
            {
                Id    = id,
                State = StateEnum.Proposed
            };

            WorkItemRepository.Add(workItem);
            return(workItem);
        }
Beispiel #2
0
        public void Delete()
        {
            switch (State)
            {
            case StateEnum.Proposed:
                WorkItemRepository.Delete(this);
                break;

            case StateEnum.Active:
                Console.WriteLine("Work Item is already active and cannot be deleted.");
                break;

            case StateEnum.Resolved:
                Console.WriteLine("Work Item is already resolved and cannot be deleted.");
                break;

            case StateEnum.Closed:
                WorkItemRepository.Delete(this);
                break;
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var workItemRepository = new WorkItemRepository();

            WorkItem.Init(workItemRepository);
            string title = null, desc = null;
            string command;
            int    id;

            try
            {
                command = args[0].ToLower();
                id      = int.Parse(args[1]);

                if (args.Count() > 2)
                {
                    title = args[2];
                    desc  = args[3];
                }
            }
            catch (Exception)
            {
                PrintUsage();
                return;
            }

            try
            {
                WorkItem workItem;
                switch (command)
                {
                case "create":
                    workItem = WorkItem.Create(id);
                    workItem.Edit(title, desc);
                    workItem.Print();
                    break;

                case "update":
                    workItem = WorkItem.FindById(id);
                    workItem.Edit(title, desc);
                    workItem.Print();
                    break;

                case "open":
                    workItem = WorkItem.FindById(id);
                    workItem.Open();
                    break;

                case "resolve":
                    workItem = WorkItem.FindById(id);
                    workItem.Resolve();
                    break;

                case "close":
                    workItem = WorkItem.FindById(id);
                    workItem.Close();
                    break;

                case "delete":
                    workItem = WorkItem.FindById(id);
                    workItem.Delete();
                    break;

                case "print":
                    workItem = WorkItem.FindById(id);
                    workItem.Print();
                    break;
                }

                workItemRepository.Save();
            }
            catch (Exception)
            {
                PrintUsage();
            }
        }
Beispiel #4
0
 public static WorkItem FindById(int id)
 {
     return(WorkItemRepository.FindById(id));
 }
Beispiel #5
0
 public static void Init(WorkItemRepository workItemRepository)
 {
     WorkItemRepository = workItemRepository;
 }