public static bool BarAttachement_Download(this IUser currentUser, Attachment attachment) { if (DIContainer.Resolve<Authorizer>().Attachment_Edit(attachment)) return true; //处理仅允许注册用户下载 //if (thread.OnlyAllowRegisteredUserDownload && currentUser == null) // return false; //处理售价 if (attachment.Price <= 0) return true; AttachmentDownloadService attachementDownloadService = new AttachmentDownloadService(); if (currentUser != null && attachementDownloadService.IsDownloaded(currentUser.UserId, attachment.AttachmentId)) return true; if (currentUser != null && attachment.Price < currentUser.TradePoints) return true; return false; }
/// <summary> /// 是否拥有下载的权限 /// </summary> /// <param name="attachment"></param> /// <returns></returns> public bool Attachment_Download(Attachment attachment) { //处理仅允许注册用户下载 //if (thread.OnlyAllowRegisteredUserDownload && currentUser == null) // return false; //处理售价 if (attachment.Price <= 0) return true; //if (DIContainer.Resolve<Authorizer>().Attachment_Edit(attachment)) // return true; IUser currentUser = UserContext.CurrentUser; if (currentUser == null) return false; if (AuthorizationService.IsOwner(currentUser, attachment.UserId)) return true; AttachmentDownloadService attachementDownloadService = new AttachmentDownloadService(); if (UserContext.CurrentUser != null && attachementDownloadService.IsDownloaded(UserContext.CurrentUser.UserId, attachment.AttachmentId)) return true; return false; }