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()); }
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> Register(AmigoTenantTEventLogDTO maintenance) { maintenance.IncludeRequestLog = Settings.RequestLogEnabled; maintenance.UserId = User.Identity.GetUserId(); maintenance.Username = User.Identity.GetUsername(); return(await _logApplicationService.RegisterAmigoTenantTEventLogAsync(maintenance)); }