本文整理汇总了C#中Course.BuildMemento方法的典型用法代码示例。如果您正苦于以下问题:C# Course.BuildMemento方法的具体用法?C# Course.BuildMemento怎么用?C# Course.BuildMemento使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Course
的用法示例。
在下文中一共展示了Course.BuildMemento方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Section
public Section(Guid sectionId, Term term, Course course, string sectionNumber)
: base(sectionId)
{
var termData = term.BuildMememto();
var courseData = course.BuildMemento();
if (courseData.IsCredit &&
string.IsNullOrEmpty(courseData.ApprovalNumber) &&
string.IsNullOrEmpty(courseData.CIP))
throw new InvalidStateException(
"Your attempt to create the section failed. Set approval number or CIP at the course level first.");
if (!courseData.IsCredit &&
courseData.CreditType != CreditTypes.SpecialInterests &&
string.IsNullOrEmpty(courseData.ApprovalNumber) &&
string.IsNullOrEmpty(courseData.CIP))
throw new InvalidStateException(
"Your attempt to create a section failed. The course doesn't have an approval number or CIP, and it's not a special interests course.");
var createEvent = courseData.IsCredit
? (IEvent) new CreditSectionCreatedEvent(
sectionId,
courseData.Id,
courseData.Rubric,
courseData.CourseNumber,
termData.Id,
termData.Abbreviation,
termData.Name,
sectionNumber)
: new ContinuingEducationSectionCreatedEvent(
sectionId,
courseData.Id,
courseData.Rubric,
courseData.CourseNumber,
termData.Id,
termData.Abbreviation,
termData.Name,
sectionNumber);
ApplyEvent(createEvent);
if (courseData.IsCredit)
ChangeDates(termData.Start, termData.End);
ApplyEvent(new SectionTitleChangedEvent(
sectionId,
null,
courseData.Title));
if (!string.IsNullOrEmpty(courseData.ApprovalNumber))
ApplyEvent(new SectionApprovalNumberChangedEvent(
sectionId, courseData.ApprovalNumber));
if (!string.IsNullOrEmpty(courseData.CIP))
ApplyEvent(new SectionCIPChangedEvent(
sectionId, courseData.CIP));
foreach (var courseType in courseData.CourseTypes)
ApplyEvent(new SectionCourseTypeAddedEvent(
sectionId,
courseType,
_courseTypes.Union(new[] {courseType}).Distinct()));
ChangeCreditType(courseData.CreditType);
ApplyEvent(new SectionMadePendingEvent(sectionId));
if (!courseData.IsCredit)
ApplyEvent(new SectionCEUsChangedEvent(
sectionId, courseData.CEUs));
if (courseData.TopicCodeId != default(Guid))
{
var uow = UnitOfWorkContext.Current;
var topicCode = uow.GetById<TopicCode>(courseData.TopicCodeId);
var topicCodeData = topicCode.BuildMemento();
ApplyEvent(new SectionTopicCodeChangedEvent(
sectionId,
topicCodeData.Id,
topicCodeData.Abbreviation,
topicCodeData.Description));
}
}