public void UpdateComponent(EditedComponent newValues)
 {
   try
   {
     object projectIndexObj = Session["ProjectSelected"];
     int projectIndex = projectIndexObj == null ? 0 : (int)projectIndexObj;
     using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
     {
       session.BeginUpdate();
       IssueTracker issueTracker = (IssueTracker)session.Open(IssueTracker.PlaceInDatabase, 1, 1, false);
       Project project = issueTracker.ProjectSet.Keys[projectIndex];
       if (newValues.Id == 0)
       {
         if (newValues.Name == null)
           Console.WriteLine("Component null storeName detected in Update method");
         else
         {
           User user = lookupUser(issueTracker, session);
           Component newComponent = new Component(user, newValues.Name, newValues.Description, project);
           Placement placer = new Placement(newComponent.PlacementDatabaseNumber, 1, 1, 10000, 10000);
           newComponent.Persist(placer, session, true, true);
           issueTracker.ComponentSet.Add(newComponent);
         }
       }
       else
       {
         Component existingComponent = (Component)session.Open(newValues.Id);
         existingComponent.Name = newValues.Name;
         existingComponent.Description = newValues.Description;
         existingComponent.Project = project;
       }
       session.Commit();
     }
   }
   catch (System.Exception ex)
   {
     this.errorLabel.Text = ex.ToString();
   }
 }
 public void Create5Components(int numberOfComponents)
 {
   Component component = null;
   Component priorComponent = null;
   for (int i = 0; i < numberOfComponents; i++)
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
       session.BeginUpdate();
       IssueTracker issueTracker = (IssueTracker)session.Open(IssueTracker.PlaceInDatabase, 1, 1, false);
       User user = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Keys.Count - 1)];
       Project project = issueTracker.ProjectSet.Keys[rand.Next(issueTracker.ProjectSet.Keys.Count - 1)];
       string c = "component" + i.ToString();
       string d = "cdescription" + i.ToString();
       component = new Component(user, c, d, project);
       component.Persist(session, priorComponent ?? component);
       issueTracker.ComponentSet.Add(component);
       priorComponent = component;
       session.Commit();
     }
 }
    void createInitialObjects(IssueTracker issueTracker, User user, SessionBase session)
    {
      Project project = new Project(user, "VelocityDB", "Object Database Management System");
      project.Persist(session, project);
      issueTracker.ProjectSet.Add(project);

      Component webSite = new Component(user, "Web Site", "VelocityDB.com", project);
      webSite.Persist(session, webSite);
      issueTracker.ComponentSet.Add(webSite);

      Component samples = new Component(user, "Samples", "Samples applications provided", project);
      samples.Persist(session, webSite);
      issueTracker.ComponentSet.Add(samples);

      Component collections = new Component(user, "Collections", "Any of the collection classes", project);
      collections.Persist(session, samples);
      issueTracker.ComponentSet.Add(collections);

      Component performance = new Component(user, "Performance", "Any performance issue", project);
      performance.Persist(session, collections);
      issueTracker.ComponentSet.Add(performance);

      ProductVersion version = new ProductVersion(user, "0.8", "First initial version", new DateTime(2011, 08, 01));
      version.Persist(session, version);
      issueTracker.VersionSet.Add(version);
    }