Exemplo n.º 1
0
        /// <summary>
        /// Delete the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Delete(DataPackageDeleteRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            try{
                context.Open();
                context.LogInfo(this, string.Format("/data/package/{{Identifier}} DELETE Identifier='{0}'", request.Identifier));
                DataPackage tmp = DataPackage.FromIdentifier(context, request.Identifier);
                if (tmp.OwnerId != context.UserId && context.AccessLevel != EntityAccessLevel.Administrator)
                {
                    throw new UnauthorizedAccessException("You are not authorized to delete this data package.");
                }
                tmp.Delete();
                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(Get(new GetAllDataPackages()));
        }