Beispiel #1
0
        public string ProcessDelete(string uriTemplate)
        {
            string data = "";

            if (!_command.IsCustomerOnly)
            {
                switch (uriTemplate)
                {
                case "/tickets/{id}/": RestTickets.DeleteTicket(_command, GetId(1)); break;

                case "/tickets/{id}/customers/{id}/": RestOrganizations.RemoveTicketOrganization(_command, GetId(1), GetId(3)); break;

                case "/tickets/{id}/contacts/{id}/": RestContacts.RemoveTicketContact(_command, GetId(1), GetId(3)); break;

                case "/customers/{id}/phonenumbers/{id}/": RestPhoneNumbers.RemovePhoneNumber(_command, ReferenceType.Organizations, GetId(1), GetId(3)); break;

                case "/customers/{id}/addresses/{id}/": RestAddresses.RemoveAddress(_command, ReferenceType.Organizations, GetId(1), GetId(3)); break;

                case "/customers/{id}/notes/{id}/": RestNotes.RemoveNote(_command, ReferenceType.Organizations, GetId(1), GetId(3)); break;

                //Commented in ticket 8867.
                //case "/customers/{id}/products/{id}/": data = RestProducts.RemoveOrganizationProduct(_command, GetId(1), GetId(3)); break;
                case "/customers/{id}/products/{id}/customerproduct/{id}/": data = RestOrganizationProducts.DeleteOrganizationProductItem(_command, GetId(1), GetId(3), GetId(5)); break;

                case "/customers/{id}/": throw new RestException(HttpStatusCode.Unused, "Deletion at the customer level is temporarily disabled. We apologize for any inconvenience.");                         //RestOrganizations.DeleteOrganization(_command, GetId(1)); break;

                case "/contacts/{id}/": RestContacts.DeleteContact(_command, GetId(1)); break;

                case "/contacts/{id}/phonenumbers/{id}/": RestPhoneNumbers.RemovePhoneNumber(_command, ReferenceType.Users, GetId(1), GetId(3)); break;

                case "/contacts/{id}/addresses/{id}/": RestAddresses.RemoveAddress(_command, ReferenceType.Users, GetId(1), GetId(3)); break;

                case "/assets/{id}/": data = RestAssets.JunkAsset(_command, GetId(1)); break;

                case "/assets/{id}/assignments/": data = RestAssetAssignments.ReturnAsset(_command, GetId(1)); break;

                case "/assets/{id}/tickets/{id}/": data = RestAssets.DeleteTicketAsset(_command, GetId(1), GetId(3)); break;

                case "/assets/{id}/attachments/{id}/":
                {
                    int attachmentID = GetId(3);
                    ModelAPI.AttachmentAPI.DeleteAttachment(attachmentID, AttachmentProxy.References.Assets, GetId(1));
                    //data = RestAttachments.DeleteAttachment(_command, GetId(1), GetId(3));
                    data = RestAttachments.GetAttachmentsAsXML(_command, attachmentID);
                }
                break;

                case "/users/{id}/": RestUsers.DeleteUser(_command, GetId(1)); break;

                case "/products/{id}/": data = RestProducts.DeleteProduct(_command, GetId(1)); break;

                case "/products/{id}/versions/{id}/": data = RestVersions.DeleteVersion(_command, GetId(3)); break;

                default: throw new RestException(HttpStatusCode.NotFound);
                }
            }
            return(data);
        }
Beispiel #2
0
        public string ProcessPut(string uriTemplate)
        {
            string data = "";

            _command.StatusCode = HttpStatusCode.Accepted;
            if (!_command.IsCustomerOnly)
            {
                switch (uriTemplate)
                {
                case "/tickets/{id}/": data = RestTickets.UpdateTicket(_command, GetId(1)); break;

                case "/tickets/{id}/actions/{id}/": data = RestActions.UpdateAction(_command, GetId(3)); break;

                case "/customers/{id}/": data = RestOrganizations.UpdateOrganization(_command, GetId(1)); break;

                case "/customers/{id}/contacts/{id}/": data = RestContacts.UpdateContact(_command, GetId(3)); break;

                case "/customers/{id}/phonenumbers/{id}/": RestPhoneNumbers.UpdatePhoneNumber(_command, GetId(3)); break;

                case "/customers/{id}/addresses/{id}/": RestAddresses.UpdateAddress(_command, GetId(3)); break;

                case "/customers/{id}/products/{id}/customerproduct/{id}/": data = RestOrganizationProducts.UpdateOrganizationProductItem(_command, GetId(1), GetId(3), GetId(5)); break;

                case "/contacts/{id}/": data = RestContacts.UpdateContact(_command, GetId(1)); break;

                case "/contacts/{id}/phonenumbers/{id}/": RestPhoneNumbers.UpdatePhoneNumber(_command, GetId(3)); break;

                case "/contacts/{id}/addresses/{id}/": RestAddresses.UpdateAddress(_command, GetId(3)); break;

                case "/assets/{id}/": data = RestAssets.UpdateAsset(_command, GetId(1)); break;

                case "/users/{id}/": data = RestUsers.UpdateUser(_command, GetId(1)); break;

                case "/products/{id}/": data = RestProducts.UpdateProduct(_command, GetId(1)); break;

                case "/products/{id}/versions/{id}/": data = RestVersions.UpdateVersion(_command, GetId(3)); break;

                default: throw new RestException(HttpStatusCode.NotFound);
                }
            }
            else
            {
                switch (uriTemplate)
                {
                case "/tickets/{id}/": data = RestTickets.UpdateCustomerTicket(_command, GetId(1)); break;

                case "/tickets/{id}/actions/{id}/": data = RestActions.UpdateCustomerAction(_command, GetId(3)); break;

                //case "/customers/{id}/": data = RestOrganizations.UpdateOrganization(_command, GetId(1)); break;
                //case "/customers/{id}/contacts/{id}/": data = RestContacts.UpdateContact(_command, GetId(3)); break;
                //case "/customers/{id}/phonenumbers/{id}/": RestPhoneNumbers.UpdatePhoneNumber(_command, GetId(3)); break;
                //case "/customers/{id}/addresses/{id}/": RestAddresses.UpdateAddress(_command, GetId(3)); break;
                //case "/contacts/{id}/": data = RestContacts.UpdateContact(_command, GetId(1)); break;
                //case "/contacts/{id}/phonenumbers/{id}/": RestPhoneNumbers.UpdatePhoneNumber(_command, GetId(3)); break;
                //case "/contacts/{id}/addresses/{id}/": RestAddresses.UpdateAddress(_command, GetId(3)); break;
                //case "/users/{id}/": data = RestUsers.UpdateUser(_command, GetId(1)); break;
                //case "/products/{id}/": data = RestProducts.UpdateProduct(_command, GetId(1)); break;
                //case "/products/{id}/versions/{id}/": data = RestVersions.UpdateVersion(_command, GetId(3)); break;
                default: throw new RestException(HttpStatusCode.NotFound);
                }
            }
            return(data);
        }
Beispiel #3
0
        public string ProcessPost(string uriTemplate)
        {
            string data = "";

            _command.StatusCode = HttpStatusCode.Created;

            if (!_command.IsCustomerOnly)
            {
                switch (uriTemplate)
                {
                case "/tickets/": data = RestTickets.CreateTicket(_command); break;

                case "/tickets/{id}/customers/{id}/": data = RestOrganizations.AddTicketOrganization(_command, GetId(1), GetId(3)); break;

                case "/tickets/{id}/contacts/{id}/": data = RestContacts.AddTicketContact(_command, GetId(1), GetId(3)); break;

                case "/tickets/{id}/actions/": data = RestActions.CreateAction(_command, GetId(1)); break;

                case "/tickets/{id}/actions/{id}/attachments/": data = RestAttachments.CreateAttachment(_command, GetId(1), GetId(3)); break;

                case "/tickets/{id}/subscribe/{id}/": data = RestSubscriptions.SubscribeToTicket(_command, GetId(1), GetId(3)); break;

                case "/tickets/{id}/unsubscribe/{id}/": data = RestSubscriptions.UnSubscribeFromTicket(_command, GetId(1), GetId(3)); break;

                case "/tickets/assignmenthistory/": data = RestTickets.GetTicketAssignments(_command, isPost: true); break;    //vv

                case "/customers/": data = RestOrganizations.CreateOrganization(_command); break;

                case "/customers/{id}/phonenumbers/": data = RestPhoneNumbers.AddPhoneNumber(_command, ReferenceType.Organizations, GetId(1)); break;

                case "/customers/{id}/addresses/": data = RestAddresses.AddAddress(_command, ReferenceType.Organizations, GetId(1)); break;

                case "/customers/{id}/notes/": data = RestNotes.AddNote(_command, ReferenceType.Organizations, GetId(1)); break;

                case "/customers/{id}/contacts/": data = RestContacts.CreateContact(_command, GetId(1)); break;

                case "/customers/{id}/products/{id}/": data = RestOrganizationProducts.CreateOrganizationProduct(_command, GetId(1), GetId(3)); break;

                case "/contacts/": data = RestContacts.CreateContact(_command, null); break;

                case "/contacts/{id}/addresses/": data = RestAddresses.AddAddress(_command, ReferenceType.Users, GetId(1)); break;

                case "/contacts/{id}/phonenumbers/": data = RestPhoneNumbers.AddPhoneNumber(_command, ReferenceType.Users, GetId(1)); break;

                case "/products/": data = RestProducts.CreateProduct(_command); break;

                case "/products/{id}/versions/": data = RestVersions.CreateVersion(_command, GetId(1)); break;

                case "/assets/": data = RestAssets.CreateAsset(_command); break;

                case "/assets/{id}/assignments/": data = RestAssetAssignments.AddAssetAssignment(_command, GetId(1)); break;

                case "/assets/{id}/tickets/{id}/": data = RestAssets.AddTicketAsset(_command, GetId(1), GetId(3)); break;

                case "/assets/{id}/attachments/": data = RestAttachments.CreateAttachment(_command, GetId(1)); break;

                case "/users/": data = RestUsers.CreateUser(_command); break;

                default: throw new RestException(HttpStatusCode.NotFound);
                }
            }
            else
            {
                switch (uriTemplate)
                {
                case "/tickets/": data = RestTickets.CreateCustomerTicket(_command); break;

                //case "/tickets/{id}/customers/{id}/": data = RestOrganizations.AddTicketOrganization(_command, GetId(1), GetId(3)); break;
                //case "/tickets/{id}/contacts/{id}/": data = RestContacts.AddTicketContact(_command, GetId(1), GetId(3)); break;
                case "/tickets/{id}/actions/": data = RestActions.CreateCustomerAction(_command, GetId(1)); break;

                //case "/customers/": data = RestOrganizations.CreateOrganization(_command); break;
                //case "/customers/{id}/phonenumbers/": data = RestPhoneNumbers.AddPhoneNumber(_command, ReferenceType.Organizations, GetId(1)); break;
                //case "/customers/{id}/addresses/": data = RestAddresses.AddAddress(_command, ReferenceType.Organizations, GetId(1)); break;
                //case "/customers/{id}/notes/": data = RestNotes.AddNote(_command, ReferenceType.Organizations, GetId(1)); break;
                //case "/customers/{id}/contacts/": data = RestContacts.CreateContact(_command, GetId(1)); break;
                //case "/contacts/{id}/addresses/": data = RestAddresses.AddAddress(_command, ReferenceType.Users, GetId(1)); break;
                //case "/contacts/{id}/phonenumbers/": data = RestPhoneNumbers.AddPhoneNumber(_command, ReferenceType.Users, GetId(1)); break;
                //case "/products/": data = RestProducts.CreateProduct(_command); break;
                //case "/products/{id}/versions/": data = RestVersions.CreateVersion(_command, GetId(1)); break;
                //case "/users/": data = RestUsers.CreateUser(_command); break;
                default: throw new RestException(HttpStatusCode.NotFound);
                }
            }
            return(data);
        }