public static string GetOrganizationProductVersionItems(RestCommand command, int organizationID, int productID, int productVersionID) { Organization item = Organizations.GetOrganization(command.LoginUser, organizationID); if (item == null || item.ParentID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Product product = Products.GetProduct(command.LoginUser, productID); if (product == null || product.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.NotFound); } ProductVersion productVersion = ProductVersions.GetProductVersion(command.LoginUser, productVersionID); if (productVersion == null || productVersion.ProductID != product.ProductID) { throw new RestException(HttpStatusCode.NotFound); } OrganizationProductsView organizationProductsView = new OrganizationProductsView(command.LoginUser); organizationProductsView.LoadByOrganizationProductAndVersionIDs(organizationID, productID, productVersionID); return(organizationProductsView.GetXml("OrganizationProducts", "OrganizationProduct", true, command.Filters)); }
public static string GetProductVersion(RestCommand command, int productVersionID) { ProductVersion productVersion = ProductVersions.GetProductVersion(command.LoginUser, productVersionID); if (productVersion.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(productVersion.GetXml("ProductVersion", true)); }
public static string UpdateVersion(RestCommand command, int id) { ProductVersion item = ProductVersions.GetProductVersion(command.LoginUser, id); if (item == null) { throw new RestException(HttpStatusCode.BadRequest); } if (Products.GetProduct(command.LoginUser, item.ProductID).OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } item.ReadFromXml(command.Data, false); item.Collection.Save(); item.UpdateCustomFieldsFromXml(command.Data); return(ProductVersionsView.GetProductVersionsViewItem(command.LoginUser, item.ProductVersionID).GetXml("Version", true)); }
public static string DeleteVersion(RestCommand command, int id) { ProductVersion item = ProductVersions.GetProductVersion(command.LoginUser, id); if (item == null) { throw new RestException(HttpStatusCode.BadRequest); } if (Products.GetProduct(command.LoginUser, item.ProductID).OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } string result = item.GetXml("Version", true); ProductVersions productVersions = new ProductVersions(command.LoginUser); using (SqlCommand dbCommand = new SqlCommand()) { dbCommand.CommandText = "DELETE FROM OrganizationProducts WHERE (ProductVersionID = @ProductVersionID)"; dbCommand.CommandType = CommandType.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddWithValue("@ProductVersionID", id); productVersions.ExecuteNonQuery(dbCommand, "OrganizationProducts"); dbCommand.CommandText = "UPDATE Tickets SET SolvedVersionID = null WHERE (SolvedVersionID = @ProductVersionID)"; dbCommand.CommandType = CommandType.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddWithValue("@ProductVersionID", id); productVersions.ExecuteNonQuery(dbCommand, "Tickets"); dbCommand.CommandText = "UPDATE Tickets SET ReportedVersionID = null WHERE (ReportedVersionID = @ProductVersionID)"; dbCommand.CommandType = CommandType.Text; dbCommand.Parameters.Clear(); dbCommand.Parameters.AddWithValue("@ProductVersionID", id); productVersions.ExecuteNonQuery(dbCommand, "Tickets"); } item.Delete(); item.Collection.Save(); return(result); }