コード例 #1
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var post = await _context.Posts.FindAsync(request.id);

                _context.Remove(post);
                await _context.SaveChangesAsync();

                return(Unit.Value);
            }
コード例 #2
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var activity = await _datacontext.Activities.FindAsync(request.ActivityId);

                if (activity == null)
                {
                    throw new RestException(HttpStatusCode.NotFound, new { activity = "Not Found" });
                }

                _datacontext.Remove(activity);

                // Handler Logic
                var success = await _datacontext.SaveChangesAsync() > 0;


                if (success)
                {
                    return(Unit.Value);
                }
                throw new Exception("Problem Delete Activity");
            }