public void Handle(PreAddDomainObjectEvent <Thread> evnt) { if (this.TotalMarks < evnt.DomainObject.Marks) { throw new DomainException(ForumValidationError.ThreadAuthorTotalMarksNotEnough.GetName()); } }
private void Handle(PreAddDomainObjectEvent <ForumUser> evnt) { IList <ForumUser> existingUsers = Repository.Find <ForumUser>(new FindForumUsersEvent(evnt.DomainObject.UserName)); if (existingUsers.Count > 0) { throw new InvalidOperationException(string.Format("用户名'{0}'已被注册。", evnt.DomainObject.UserName)); } }
private void Handle(PreAddDomainObjectEvent <Group> evnt) { IList <Group> existingGroups = Repository.Find <Group, FindGroupsEvent>(e => e.Subject = evnt.DomainObject.Subject); if (existingGroups != null && existingGroups.Count > 0) { throw new DuplicatedNameException(ForumValidationError.DuplicateGroupSubject.GetName(), evnt.DomainObject.Subject); } }
private void Handle(PreAddDomainObjectEvent <User> evnt) { IList <User> existingUsers = Repository.Find <User, FindUsersEvent>(evt => evt.UserName = evnt.DomainObject.UserName); if (existingUsers != null && existingUsers.Count > 0) { throw new DuplicatedNameException(ForumValidationError.DuplicateUserName.GetName(), evnt.DomainObject.UserName); } }
private void Handle(PreAddDomainObjectEvent <Topic> evnt) { if (this.Id == evnt.DomainObject.CreatedBy) { if (this.TotalMarks < evnt.DomainObject.TotalMarks) { throw new InvalidOperationException("用户积分不足。"); } } }
private void Handle(PreAddDomainObjectEvent <Section> evnt) { IList <Section> existingSections = Repository.Find <Section, FindSectionsEvent>( e => { e.GroupId = evnt.DomainObject.GroupId; e.Subject = evnt.DomainObject.Subject; }); if (existingSections != null && existingSections.Count > 0) { throw new DuplicatedNameException(ForumValidationError.DuplicateSectionSubject.GetName(), evnt.DomainObject.Subject); } }