public async Task RegisterAmigoTenanttServiceAsync_SendCommand_To_Bus_SendAsync()
        {
            DateTime       baseTime   = new DateTime(2017, 01, 11, 7, 0, 0);
            DateTimeOffset sourceTime = new DateTimeOffset(baseTime, TimeZoneInfo.Local.GetUtcOffset(baseTime));

            var request = new AmigoTenantTEventLogDTO()
            {
                ActivityCode = "001", ReportedActivityTimeZone = "America/New_York", ReportedActivityDate = sourceTime
            };
            var command = new RegisterAmigoTenanttEventLogCommand();

            var model = activityTypeApplicationService.SearchActivityByCodeAsync(request.ActivityCode).Result.ActivityTypeId;

            DateTimeZone tz = DateTimeZoneProviders.Tzdb.GetZoneOrNull(request.ReportedActivityTimeZone);


            A.CallTo(() => _mapper.Map <AmigoTenantTEventLogDTO, RegisterAmigoTenanttEventLogCommand>(request)).Returns(command);

            //**********   ACT   **********
            var resp = amigoTenantTEventLogApplicationService.RegisterAmigoTenantTEventLogAsync(request);

            //**********   ASSERT    **********
            A.CallTo(() => _bus.SendAsync(command)).WithAnyArguments().MustHaveHappened(Repeated.Exactly.Once);
            Assert.NotNull(resp);
        }
        public async Task <ResponseDTO> ValidateAuthorizationAsync(AuthorizationRequest search, int?amigoTenantTUserId)
        {
            var activityType = await _activityTypeService.SearchActivityByCodeAsync(Constants.ActivityTypeCode.Authentication);

            var command = _mapper.Map <AuthorizationRequest, UpdateDeviceAuthorizationCommand>(search);

            command.AssignedAmigoTenantTUserId = amigoTenantTUserId;
            command.ActivityTypeId             = activityType.ActivityTypeId;

            //Execute Command

            var commandResult = await _bus.SendAsync(command);

            var reponseDTO = new ResponseDTO <AmigoTenantTUserDTO>();

            reponseDTO.IsValid = commandResult.IsCorrect;
            foreach (var item in commandResult.Errors)
            {
                var appMsg = new ApplicationMessage()
                {
                    Key = null, Message = item
                };
                reponseDTO.Messages.Add(appMsg);
            }
            reponseDTO.Data = _mapper.Map <AmigoTenantTUser, AmigoTenantTUserDTO>(commandResult.Data);

            return(reponseDTO);
        }
        public async Task <ResponseDTO> RegisterAmigoTenantTEventLogAsync(AmigoTenantTEventLogDTO maintenance)
        {
            var model = await _activityApplicationService.SearchActivityByCodeAsync(maintenance.ActivityCode);

            if (model != null)
            {
                maintenance.ActivityTypeId = model.ActivityTypeId;
            }

            DateTimeZone tz = DateTimeZoneProviders.Tzdb.GetZoneOrNull(maintenance.ReportedActivityTimeZone);

            if (!string.IsNullOrEmpty(tz.Id))
            {
                maintenance.ReportedActivityTimeZone = tz.Id;
            }
            maintenance.ConvertedActivityUTC = DateTimeUTCCommon.DatetimeToDateUTC(maintenance.ReportedActivityDate);

            var command = _mapper.Map <AmigoTenantTEventLogDTO, RegisterAmigoTenanttEventLogCommand>(maintenance);

            //Execute Command

            var resp = await _bus.SendAsync(command);

            return(resp.ToResponse());
        }
Beispiel #4
0
        public void UpdateAmigoTenantTServiceForApproveAsync_SendCommand_To_Bus_SendAsync()
        {
            // save SidePanel
            var maintenance = new AmigoTenantTServiceRequest();
            var command     = new UpdateAmigoTenantTServiceApproveCommand()
            {
            };

            A.CallTo(() => _mapper.Map <AmigoTenantTServiceRequest, UpdateAmigoTenantTServiceApproveCommand>(maintenance)).Returns(command);

            A.CallTo(() => _activityTypeService.SearchActivityByCodeAsync(Constants.ActivityTypeCode.EditbeforeApproval)).Invokes(() => command.ActivityTypeId = 1)
            .ReturnsLazily(() => Task.FromResult(new ActivityTypeDTO()));

            //**********   ACT   **********
            var resp = _appService.UpdateAmigoTenantTServiceForApproveAsync(maintenance);


            //**********   ASSERT    **********
            Assert.NotNull(resp);

            A.CallTo(() => _bus.SendAsync(command)).MustHaveHappened(Repeated.Exactly.Once);
        }