Esempio n. 1
0
        /// <summary>
        /// Rejects uploaded entity (item or app)
        /// </summary>
        /// <typeparam name="T">Entity type (see <see cref="IApprovalEntity"/>)</typeparam>
        /// <param name="entity">Entity object that should be rejected</param>
        /// <returns>()</returns>
        public static T Reject <T>(T entity) where T : class, IApprovalEntity
        {
            var body = GetIdAndType(entity);

            body.Action   = ApprovalConclusions.Reject.ToString();
            body.Comments = string.Empty;

            RestController.HttpRequestJson(UriCxm.Approve, Method.POST, body, user: TestConfig.AdminUser);
            return((T)Convert.ChangeType(
                       body.EntityType == (int)ApprovalEntities.Item
                    ? ItemApi.GetById(body.EntityId)
                    : (object)AppApi.GetById((long)body.EntityId),
                       typeof(T)));
        }
Esempio n. 2
0
        /// <summary>
        /// Request approval of uploaded entity (item or app)
        /// </summary>
        /// <typeparam name="T">Entity type</typeparam>
        /// <param name="entity">Entity object that should be approved (see <see cref="IApprovalEntity"/>)</param>
        /// <param name="tenants">Tenant(s) where the entity is located</param>
        public static T RequestApproval <T>(T entity, params TenantTitle[] tenants) where T : class, IApprovalEntity
        {
            var temp      = GetIdAndType(entity);
            var tenantIds = Array.ConvertAll(tenants, value => (int)value);
            var body      = new ApprovalRequest
            {
                EntityId   = temp.EntityId,
                Tenants    = tenantIds,
                Comments   = string.Empty,
                EntityType = temp.EntityType
            };

            RestController.HttpRequestJson(UriCxm.ApproveRequest, Method.POST, body, user: TestConfig.AdminUser);
            return((T)Convert.ChangeType(
                       body.EntityType == (int)ApprovalEntities.Item
                    ? ItemApi.GetById(body.EntityId)
                    : (object)AppApi.GetById((long)body.EntityId),
                       typeof(T)));
        }