Пример #1
0
        public Task <CourseData> Handle(RemoveCourse request)
        {
            _repository.Context.Remove(Course);

            return(Task.FromResult(new CourseData
            {
                Id = Course.Id,
                RowVersion = Course.RowVersion
            }));
        }
Пример #2
0
        public async Task <CourseData> Apply(
            RemoveCourse request, Func <RemoveCourse, Task <CourseData> > next)
        {
            using (var scope = _repository.Scopes.Create())
            {
                var resource = request.Resource;
                if (Course == null && resource != null)
                {
                    Course = await _repository.FetchByIdAsync <Course>(resource.Id);

                    Env.Use(Course);
                }

                var result = await next(request);

                await scope.SaveChangesAsync();

                return(result);
            }
        }