public Project CreateProject(string projectName, string user)
 {
     var inactiveUserAccount = Session.Query<UserAccount>().Where(u => u.Username == user && u.Status == UserStatus.Active).Count();
     if (inactiveUserAccount != 1)
         throw new ArgumentException(string.Format("Cannot create new project '{0}' - {1} is an inactive user.", projectName, user));
     var existingProjects = Session.Query<Project>().Where(p => p.Name == projectName).Count();
     if (existingProjects > 0)
         throw new ArgumentException(string.Format("Cannot create new project '{0}' - this project name is already in use.", projectName));
     var project = new Project(projectName, user);
     Session.Store(project, projectName);
     Session.SaveChanges();
     return project;
 }
 private void ValidateProjectAndUser(string projectName, Project project, string actingUser)
 {
     if (project == null)
         throw new ArgumentException(string.Format("Could not find Project {0}.", projectName));
     if (!project.Users.Contains(actingUser))
         throw new ArgumentException(string.Format("{0} is not authorised to edit Project {1}.", actingUser, projectName));
 }