Skip to content

Commit

Permalink
Added Project Version Management methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tdietrich513 committed Jan 24, 2013
1 parent fa6f503 commit 7320fb6
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/YouTrackSharp/Projects/ProjectManagement.cs
Expand Up @@ -79,6 +79,17 @@ public IEnumerable<ProjectResolutionType> GetResolutions()
return _connection.Get<IEnumerable<ProjectResolutionType>>("project/resolutions");
}

public IEnumerable<ProjectVersion> GetVersions(string versionBundleName)
{
var x = _connection.Get<IEnumerable<ProjectVersion>>(string.Format("admin/customfield/versionBundle/{0}", versionBundleName));
return x;
}

public IEnumerable<ProjectVersion> GetVersions(Project project)
{
return GetVersions(project.Name + "%20Versions");
}

public Project GetProject(string projectName)
{
return _connection.Get<Project>(String.Format("admin/project/{0}", projectName));
Expand All @@ -87,5 +98,15 @@ public void AddSubsystem(string projectName, string subsystem)
{
_connection.Put(String.Format("admin/project/{0}/subsystem/{1}", projectName, subsystem), null);
}

public void AddVersion(Project project, ProjectVersion version)
{
AddVersion(project.Name + "%20Versions", version);
}

public void AddVersion(string versionBundleName, ProjectVersion version)
{
_connection.Put(String.Format("admin/customfield/versionBundle/{0}/{1}", versionBundleName, version.GetQueryString()), null);
}
}
}
71 changes: 71 additions & 0 deletions src/YouTrackSharp/Projects/ProjectVersion.cs
@@ -0,0 +1,71 @@
#region License

// Distributed under the BSD License
//
// YouTrackSharp Copyright (c) 2010-2012, Hadi Hariri and Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Hadi Hariri nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// <COPYRIGHTHOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#endregion

using JsonFx.Json;

namespace YouTrackSharp.Projects
{
using System.Text;

public class ProjectVersion
{
public string Name { get; set; }
public string BuildName { get; set; }
public string Description { get; set; }
public int? ColorIndex { get; set; }
public string ReleaseDate { get; set; }
[JsonName("released")]
public bool? IsReleased { get; set; }
[JsonName("archived")]
public bool? IsArchived { get; set; }

public string GetQueryString()
{
var sb = new StringBuilder();
sb.Append(Name);
if (
!(!string.IsNullOrEmpty(BuildName) || !string.IsNullOrEmpty(Description) || ColorIndex.HasValue
|| !string.IsNullOrEmpty(ReleaseDate) || IsReleased.HasValue || IsArchived.HasValue)) return sb.ToString();

sb.Append("?");
var description = "description=" + Description.Replace(" ", "+");
var colorindex = "colorIndex=" + ColorIndex;
var releaseDate = "releasedate=" + ReleaseDate;
var released = "released=" + IsReleased;
var archived = "archived=" + IsArchived;

sb.Append(string.Join("&", new[] {description, colorindex, releaseDate, released, archived}));
return sb.ToString();
}
}
}

0 comments on commit 7320fb6

Please sign in to comment.