Example #1
0
        public static string CreateVersion(RestCommand command, int productID)
        {
            if (Products.GetProduct(command.LoginUser, productID).OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            ProductVersions items = new ProductVersions(command.LoginUser);
            ProductVersion  item  = items.AddNewProductVersion();

            item.ReadFromXml(command.Data, true);
            item.ProductID = productID;
            item.Collection.Save();
            item.UpdateCustomFieldsFromXml(command.Data);
            return(ProductVersionsView.GetProductVersionsViewItem(command.LoginUser, item.ProductVersionID).GetXml("Version", true));
        }
    public override bool Save()
    {
        if (textVersionNumber.Text.Trim() == "")
        {
            _manager.Alert("Please enter a version number.");
            return(false);
        }

        ProductVersion  version;
        ProductVersions versions = new ProductVersions(UserSession.LoginUser);;

        if (_versionID < 0)
        {
            version = versions.AddNewProductVersion();
        }
        else
        {
            versions.LoadByProductVersionID(_versionID);
            if (versions.IsEmpty)
            {
                return(false);
            }
            version = versions[0];
        }

        version.VersionNumber          = textVersionNumber.Text;
        version.ProductVersionStatusID = int.Parse(cmbStatus.SelectedValue);
        version.ProductID   = int.Parse(cmbProduct.SelectedValue);
        version.Description = editorDescription.Content;
        version.IsReleased  = cbReleased.Checked;
        if (dpRelease.SelectedDate == null)
        {
            version.ReleaseDate = null;
        }
        else
        {
            DateTime date = new DateTime(((DateTime)dpRelease.SelectedDate).Ticks);
            version.ReleaseDate = DataUtils.DateToUtc(UserSession.LoginUser, date);
        }

        version.Collection.Save();
        (new OrganizationProducts(UserSession.LoginUser)).UpdateVersionProduct(version.ProductVersionID, version.ProductID);

        _fieldControls.RefID = version.ProductVersionID;
        _fieldControls.SaveCustomFields();

        return(true);
    }