示例#1
0
        protected async override Task Handle(UpdateStudentCommand request, CancellationToken cancellationToken)
        {
            var student = context.Students.Find(request.Id);

            student.DA        = DaNumber.Parse(request.DA);
            student.FirstName = request.FirstName;
            student.LastName  = request.LastName;

            await context.SaveChangesAsync(cancellationToken);
        }
        protected async override Task Handle(CreateStudentCommand request, CancellationToken cancellationToken)
        {
            var student = new Student()
            {
                DA        = DaNumber.Parse(request.DA),
                FirstName = request.FirstName,
                LastName  = request.LastName
            };

            context.Students.Add(student);

            await context.SaveChangesAsync(cancellationToken);
        }