Example #1
0
    public override bool Save()
    {
        if (_referenceType == ReferenceType.Products || _referenceType == ReferenceType.ProductVersions || _referenceType == ReferenceType.OrganizationProducts)
        {
            Products products = new Products(UserSession.LoginUser);

            foreach (GridDataItem item in gridOrganizations.Items)
            {
                if (item.Selected)
                {
                    if (_referenceID2 < 0)
                    {
                        products.AddCustomer(int.Parse(item["OrganizationID"].Text), _referenceID1);
                    }
                    else
                    {
                        products.AddCustomer(int.Parse(item["OrganizationID"].Text), _referenceID1, _referenceID2);
                    }
                }
            }
            return(true);
        }
        else if (_referenceType == ReferenceType.Tickets)
        {
            Tickets tickets = new Tickets(UserSession.LoginUser);

            foreach (GridDataItem item in gridOrganizations.Items)
            {
                if (item.Selected)
                {
                    tickets.AddOrganization(int.Parse(item["OrganizationID"].Text), _referenceID1);
                }
            }
            return(true);
        }

        return(false);
    }
        public static string AddOrganizationProduct(RestCommand command, int organizationID, int productID)
        {
            Organization organization = Organizations.GetOrganization(command.LoginUser, organizationID);

            if (organization == null || organization.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.Unauthorized);
            }

            Products products = new Products(command.LoginUser);

            products.AddCustomer(organizationID, productID);
            return(OrganizationsView.GetOrganizationsViewItem(command.LoginUser, organizationID).GetXml("Customer", true));
        }