Beispiel #1
0
        public void RemoveAccessForUser(long attachmentId, long userId)
        {
            Attachment a = GetObject(attachmentId);

            if (((Account)Server.HttpContext.Session["Account"]).Id != a.UploaderId)
            {
                throw new Exception("只有附件上传者才可以修改附件的访问者");
            }

            IAttachmentAccountRepository attachmentAccountRepository = StructureMap.ObjectFactory.GetInstance <IAttachmentAccountRepository>();
            var o = attachmentAccountRepository.GetFirstOrDefaultObject(x => x.AccessableAttachments_Id == attachmentId && x.AccessableUsers_Id == userId);

            attachmentAccountRepository.Delete(o);
        }
Beispiel #2
0
        public void GiveAccessToUser(long attachmentId, long userId)
        {
            Attachment a = GetObject(attachmentId);

            if (((Account)Server.HttpContext.Session["Account"]).Id != a.UploaderId)
            {
                throw new Exception("只有附件上传者才可以修改附件的访问者");
            }

            IAttachmentAccountRepository attachmentAccountRepository = StructureMap.ObjectFactory.GetInstance <IAttachmentAccountRepository>();

            attachmentAccountRepository.Add(new AttachmentAccount()
            {
                AccessableAttachments_Id = attachmentId,
                AccessableUsers_Id       = userId,
            });
            attachmentAccountRepository.SaveChanges();
        }