예제 #1
0
            public async Task <string> Handle(Command request, CancellationToken cancellationToken)
            {
                var unavailability = new Unavailability(request.From, request.To, request.Reason, request.Comment);

                _unavailabilityRepository.Insert(unavailability);
                await _unavailabilityRepository.SaveChangesAsync();

                return(unavailability.Id);
            }
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var unavailability = await _unavailabilityRepository.GetByIdAsync(request.Id);

                if (unavailability == null)
                {
                    throw new BadRequestException($"Not found unavailability with id: {request.Id}");
                }

                _unavailabilityRepository.Remove(unavailability);
                await _unavailabilityRepository.SaveChangesAsync();

                return(Unit.Value);
            }
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var unavailability = await _unavailabilityRepository.GetByIdAsync(request.Id);

                if (unavailability == null)
                {
                    throw new BadRequestException($"Not found product with id: {request.Id}");
                }

                unavailability.Update(request.From, request.To, request.Reason, request.Comment);

                _unavailabilityRepository.Update(unavailability);
                await _unavailabilityRepository.SaveChangesAsync();

                return(Unit.Value);
            }