Ejemplo n.º 1
0
        /// <summary>
        /// [Dev] Seed the Todo table with an item.
        /// </summary>
        public void DevSeedTodoItem()
        {
            while (TodoItems.Any())
            {
                TodoItems.Remove(TodoItems.First());
            }
            TodoItem newItem = new TodoItem();

            newItem.Name = "Do The Thing";
            Project proj = Projects.First();

            newItem.Project = proj;
            StatusSet statusSet = proj.ValidStatuses;

            newItem.Status = statusSet.Statuses[0];
            ChangeTracker.TrackGraph(newItem, node => node.Entry.State = node.Entry.IsKeySet ? EntityState.Unchanged : EntityState.Added);
            SaveChanges();


            /*
             * var newFile = new FileRef("test/file.jpg");
             *
             * var user = Users.FirstOrDefault();
             * var statusSet = StatusSets.FirstOrDefault();
             *
             * var project = Projects.FirstOrDefault();
             * if (project == null) {
             *  System.Console.WriteLine(" !!! Tried to create Todo without project");
             *  return;
             * }
             * EnsureDeepLoaded(Entry(project));
             * EnsureDeepLoaded(Entry(project.ValidStatuses));
             * var initItem = new TodoItem(project, project.ValidStatuses.Statuses[0]);
             * initItem.Name = "Init Item";
             * initItem.Project = Projects.FirstOrDefault();
             * initItem.Files.Add(newFile);
             * initItem.Tags = "mojo;josie;kibby";
             * if (user != null) initItem.Assignee = user;
             * else System.Console.WriteLine("NULL USER");
             * TodoItems.Add(initItem);
             * SaveChanges();*/
        }