public static string GetItemsByTicketIDOrNumber(RestCommand command, int refID, bool orderByDateCreated = false)
        {
            ActionLogsView items = new ActionLogsView(command.LoginUser);

            if (orderByDateCreated)
            {
                items.LoadByReference(refID, ReferenceType.Tickets, "DateCreated DESC");
            }
            else
            {
                items.LoadByReference(refID, ReferenceType.Tickets);
            }
            if (items.IsEmpty)
            {
                items = new ActionLogsView(command.LoginUser);
                if (orderByDateCreated)
                {
                    items.LoadByTicketNumber(refID, "DateCreated DESC");
                }
                else
                {
                    items.LoadByTicketNumber(refID);
                }
            }
            return(items.GetXml("History", "ActionItem", true, command.Filters));
        }
        public static string GetItem(RestCommand command, ReferenceType refType, int refID, int id)
        {
            ActionLogsViewItem item = ActionLogsView.GetActionLogsViewItem(command.LoginUser, id);

            if (item.OrganizationID != command.LoginUser.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(item.GetXml("ActionItem", true));
        }
        public static string GetActionLogsViewItem(RestCommand command, int actionLogID)
        {
            ActionLogsViewItem actionLogsViewItem = ActionLogsView.GetActionLogsViewItem(command.LoginUser, actionLogID);

            if (actionLogsViewItem.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(actionLogsViewItem.GetXml("ActionLogsViewItem", true));
        }
        public static string GetItems(RestCommand command, ReferenceType refType, int refID, bool orderByDateCreated = false)
        {
            ActionLogsView items = new ActionLogsView(command.LoginUser);

            if (orderByDateCreated)
            {
                items.LoadByReference(refID, refType, "DateCreated DESC");
            }
            else
            {
                items.LoadByReference(refID, refType);
            }
            return(items.GetXml("History", "ActionItem", true, command.Filters));
        }
        public static string GetActionLogsView(RestCommand command)
        {
            ActionLogsView actionLogsView = new ActionLogsView(command.LoginUser);

            actionLogsView.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(actionLogsView.GetXml("ActionLogsView", "ActionLogsViewItem", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }