Пример #1
0
        public Document(string name,
                        Course course,
                        BaseUser user, decimal price, DocumentType documentType, string description)
            : this()
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            Name       = Path.GetFileNameWithoutExtension(name.Replace("+", "-"));
            University = user.University;
            Course     = course ?? throw new ArgumentNullException(nameof(course));
            User       = user;
            Views      = 0;
            if (!string.IsNullOrEmpty(description))
            {
                Description = description;
            }
            ChangePrice(price);
            //Price = price;
            var status = Public;// GetInitState(user);

            if (status == Public)
            {
                MakePublic();
            }
            Status       = status;
            DocumentType = documentType;
        }
Пример #2
0
 public virtual void AddFollower(BaseUser follower)
 {
     if (!Equals(follower))
     {
         var follow = new Follow(this, follower);
         _followers.Add(follow);
     }
 }
Пример #3
0
 public virtual void AddDownload(BaseUser user)
 {
     if (!User.Equals(user))
     {
         var download = new UserDownloadDocument(user, this);
         DocumentDownloads.Add(download);
     }
 }
Пример #4
0
 public virtual void Flag(string messageFlagReason, BaseUser user)
 {
     if (User == user)
     {
         throw new UnauthorizedAccessException("you cannot flag your own document");
     }
     Status = Status.Flag(messageFlagReason, user);
     AddEvent(new DocumentFlaggedEvent(this));
 }
Пример #5
0
        public virtual void Flag(string messageFlagReason, BaseUser user)
        {
            if (User.Id == user.Id)
            {
                throw new UnauthorizedAccessException("you cannot flag your own question");
            }

            Status = Status.Flag(messageFlagReason, user);
        }
Пример #6
0
 public Follow(BaseUser followed, BaseUser follower)
 {
     if (followed.Id == follower.Id)
     {
         throw new ArgumentException();
     }
     Followed = followed;
     Follower = follower;
     Created  = DateTime.UtcNow;
 }
Пример #7
0
 public UserDownloadDocument(BaseUser user, Document document)
 {
     if (user.Id == document.User.Id)
     {
         throw new ArgumentException();
     }
     User     = user;
     Document = document;
     Created  = DateTime.UtcNow;
 }
Пример #8
0
        //public static readonly ItemStatus FlagStatus = new ItemStatus(ItemState.Deleted, null, null, null);

        public ItemStatus Flag(string reason, BaseUser user)
        {
            if (!ValidateFlagReason(reason))
            {
                throw new ArgumentException("reason is too long");
            }

            if (this != Public)
            {
                throw new ArgumentException("Not Flagged state");
            }
            return(new ItemStatus(ItemState.Flagged, null, reason, user));
        }
Пример #9
0
        public virtual void RemoveFollower(BaseUser follower)
        {
            var follow = new Follow(this, follower);

            _followers.Remove(follow);
        }