Esempio n. 1
0
        public static string GetOrganizationProductItem(RestCommand command, int organizationID, int productID, int organizationProductID)
        {
            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);
            }
            OrganizationProduct organizationProduct = OrganizationProducts.GetOrganizationProduct(command.LoginUser, organizationProductID);

            if (organizationProduct == null || organizationProduct.OrganizationID != organizationID)
            {
                throw new RestException(HttpStatusCode.NotFound);
            }

            OrganizationProductsView organizationProductsView = new OrganizationProductsView(command.LoginUser);

            organizationProductsView.LoadByOrganizationProductID(organizationProductID, true);

            return(organizationProductsView.GetXml("OrganizationProducts", "OrganizationProduct", true, command.Filters));
        }
Esempio n. 2
0
        public static string DeleteOrganizationProductItem(RestCommand command, int organizationID, int productID, int organizationProductID)
        {
            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);
            }
            OrganizationProduct organizationProduct = OrganizationProducts.GetOrganizationProduct(command.LoginUser, organizationProductID);

            if (organizationProduct == null || organizationProduct.OrganizationID != organizationID)
            {
                throw new RestException(HttpStatusCode.NotFound);
            }

            string result = OrganizationProductsView.GetOrganizationProductsViewItem(command.LoginUser, organizationProduct.OrganizationProductID).GetXml("OrganizationProduct", true);
            OrganizationProducts organizationProducts = new OrganizationProducts(command.LoginUser);

            organizationProducts.DeleteFromDB(organizationProductID);
            return(result);
        }
Esempio n. 3
0
        public static string UpdateOrganizationProductItem(RestCommand command, int organizationID, int productID, int organizationProductID)
        {
            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);
            }
            OrganizationProduct organizationProduct = OrganizationProducts.GetOrganizationProduct(command.LoginUser, organizationProductID);

            if (organizationProduct == null || organizationProduct.OrganizationID != organizationID)
            {
                throw new RestException(HttpStatusCode.NotFound);
            }

            organizationProduct.ReadFromXml(command.Data, false);
            organizationProduct.Collection.Save();
            organizationProduct.UpdateCustomFieldsFromXml(command.Data);

            return(OrganizationProductsView.GetOrganizationProductsViewItem(command.LoginUser, organizationProduct.OrganizationProductID).GetXml("OrganizationProduct", true));
        }
Esempio n. 4
0
    public override bool Save()
    {
        OrganizationProduct organizationProduct = null;

        if (_organizationProductID < 0)
        {
            organizationProduct = (new OrganizationProducts(UserSession.LoginUser)).AddNewOrganizationProduct();
        }
        else
        {
            organizationProduct = (OrganizationProduct)OrganizationProducts.GetOrganizationProduct(UserSession.LoginUser, _organizationProductID);
        }

        organizationProduct.OrganizationID = int.Parse(cmbCustomers.SelectedValue);
        organizationProduct.ProductID      = int.Parse(cmbProducts.SelectedValue);
        if (cmbVersions.SelectedIndex > 0)
        {
            organizationProduct.ProductVersionID = int.Parse(cmbVersions.SelectedValue);
        }
        else
        {
            organizationProduct.ProductVersionID = null;
        }
        organizationProduct.SupportExpiration = DataUtils.DateToUtc(UserSession.LoginUser, dtExpiration.SelectedDate);
        organizationProduct.Collection.Save();

        _fieldControls.RefID = organizationProduct.OrganizationProductID;
        _fieldControls.SaveCustomFields();

        return(true);
    }
Esempio n. 5
0
        public static string GetOrganizationProduct(RestCommand command, int organizationProductID)
        {
            OrganizationProduct organizationProduct = OrganizationProducts.GetOrganizationProduct(command.LoginUser, organizationProductID);

            if (organizationProduct.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(organizationProduct.GetXml("OrganizationProduct", true));
        }
Esempio n. 6
0
    private void LoadOrganizationProduct(int organizationProductID)
    {
        //LoadCustomers();
        LoadProducts();

        RadComboBoxItem item = new RadComboBoxItem();

        item.Selected = true;


        OrganizationProduct organizationProduct = (OrganizationProduct)OrganizationProducts.GetOrganizationProduct(UserSession.LoginUser, organizationProductID);

        if (organizationProduct != null)
        {
            LoadVersions(organizationProduct.ProductID);
            cmbProducts.SelectedValue = organizationProduct.ProductID.ToString();
            //cmbCustomers.SelectedValue = organizationProduct.OrganizationID.ToString();
            dtExpiration.SelectedDate = organizationProduct.SupportExpiration;
            item.Value = organizationProduct.OrganizationID.ToString();
            item.Text  = (Organizations.GetOrganization(UserSession.LoginUser, organizationProduct.OrganizationID)).Name;
            if (organizationProduct.ProductVersionID != null)
            {
                cmbVersions.SelectedValue = organizationProduct.ProductVersionID.ToString();
            }
        }
        else
        {
            cmbProducts.SelectedValue = _productID.ToString();
            //cmbCustomers.SelectedValue = _organizationID.ToString();
            item.Value = _organizationID.ToString();
            if (_organizationID > -1)
            {
                item.Text = (Organizations.GetOrganization(UserSession.LoginUser, _organizationID)).Name;
            }
            LoadVersions(int.Parse(cmbProducts.SelectedValue));
            cmbVersions.SelectedValue = _versionID.ToString();
            dtExpiration.SelectedDate = null;
        }
        cmbCustomers.Items.Add(item);
    }