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; }
public virtual void AddFollower(BaseUser follower) { if (!Equals(follower)) { var follow = new Follow(this, follower); _followers.Add(follow); } }
public virtual void AddDownload(BaseUser user) { if (!User.Equals(user)) { var download = new UserDownloadDocument(user, this); DocumentDownloads.Add(download); } }
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)); }
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); }
public Follow(BaseUser followed, BaseUser follower) { if (followed.Id == follower.Id) { throw new ArgumentException(); } Followed = followed; Follower = follower; Created = DateTime.UtcNow; }
public UserDownloadDocument(BaseUser user, Document document) { if (user.Id == document.User.Id) { throw new ArgumentException(); } User = user; Document = document; Created = DateTime.UtcNow; }
//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)); }
public virtual void RemoveFollower(BaseUser follower) { var follow = new Follow(this, follower); _followers.Remove(follow); }