Esempio n. 1
0
 public async Task <GetApplianceActivityResponse> Handle(GetApplianceActivityRequest request,
                                                         CancellationToken cancellationToken)
 {
     return(!_validator.Validate(request).IsValid
         ? new GetApplianceActivityResponse(new [] { new Error("InvalidRequest", "InvalidRequest") })
         : new GetApplianceActivityResponse(await _applianceService.GetCustomerAppliancesActivity(request.CustomerGuid)));
 }
        public async Task <GetCustomerApplianceActivityResponse> Handle(GetCustomerApplianceActivityRequest request,
                                                                        CancellationToken cancellationToken)
        {
            if (!_validator.Validate(request).IsValid)
            {
                return(new GetCustomerApplianceActivityResponse(new [] { new Error("InvalidRequest", "InvalidRequest") }));
            }

            var caretaker = await _unitOfWork.Repository.GetByGuidAsync(request.CaretakerGuid,
                                                                        $"{nameof(Caretaker.TakingCareOf)}.{nameof(CaretakerForCustomer.Customer)}");

            return(!caretaker.IsTakingCareOf(request.CustomerGuid)
                ? new GetCustomerApplianceActivityResponse(new [] { new Error("NoSuchCustomer", "Customer is not registered with Caretaker.") })
                : new GetCustomerApplianceActivityResponse(await _applianceService.GetCustomerAppliancesActivity(request.CustomerGuid)));
        }