public async Task <ResponseDTO <int> > Register(AmigoTenanttServiceDTO maintenance)
 {
     ChangingForeignKeyFromZeroToNull(maintenance);
     maintenance.IncludeRequestLog  = Settings.RequestLogEnabled;
     maintenance.AmigoTenantTUserId = User.Identity.GetUserId();
     maintenance.Username           = User.Identity.GetUsername();
     return(await _serviceApplicationService.RegisterAmigoTenanttServiceAsync(maintenance));
 }
 private void ChangingForeignKeyFromZeroToNull(AmigoTenanttServiceDTO maintenance)
 {
     if (maintenance.OriginLocationId.HasValue && maintenance.OriginLocationId == 0)
     {
         maintenance.OriginLocationId = null;
     }
     if (maintenance.DestinationLocationId.HasValue && maintenance.DestinationLocationId == 0)
     {
         maintenance.DestinationLocationId = null;
     }
     if (maintenance.DispatchingPartyId.HasValue && maintenance.DispatchingPartyId == 0)
     {
         maintenance.DispatchingPartyId = null;
     }
     if (maintenance.EquipmentSizeId.HasValue && maintenance.EquipmentSizeId == 0)
     {
         maintenance.EquipmentSizeId = null;
     }
     if (maintenance.EquipmentTypeId.HasValue && maintenance.EquipmentTypeId == 0)
     {
         maintenance.EquipmentTypeId = null;
     }
     if (maintenance.EquipmentStatusId.HasValue && maintenance.EquipmentStatusId == 0)
     {
         maintenance.EquipmentStatusId = null;
     }
     if (maintenance.CostCenterId.HasValue && maintenance.CostCenterId == 0)
     {
         maintenance.CostCenterId = null;
     }
     if (maintenance.ProductId.HasValue && maintenance.ProductId == 0)
     {
         maintenance.ProductId = null;
     }
     if (maintenance.ServiceId.HasValue && maintenance.ServiceId == 0)
     {
         maintenance.ServiceId = null;
     }
     //if (maintenance.AmigoTenantTUserId.HasValue && maintenance.AmigoTenantTUserId == 0)
     //    maintenance.AmigoTenantTUserId = null;
 }
Exemple #3
0
        public void 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 AmigoTenanttServiceDTO();
            var command = new RegisterAmigoTenanttServiceCommand();

            request.ServiceStartDate     = sourceTime;
            request.ServiceStartDateTZ   = "America/New_York";
            request.ReportedActivityDate = sourceTime;


            A.CallTo(() => _mapper.Map <AmigoTenanttServiceDTO, RegisterAmigoTenanttServiceCommand>(request)).Returns(command);

            //**********   ACT   **********
            var resp = _appService.RegisterAmigoTenanttServiceAsync(request);

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

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