diff --git a/source/backend/api/Services/PropertyService.cs b/source/backend/api/Services/PropertyService.cs index 8b4302a7fa..51f2cd8884 100644 --- a/source/backend/api/Services/PropertyService.cs +++ b/source/backend/api/Services/PropertyService.cs @@ -230,6 +230,11 @@ public PimsPropertyActivity CreateActivity(PimsPropertyActivity propertyActivity _logger.LogInformation("Creating property Activity..."); _user.ThrowIfNotAuthorized(Permissions.ManagementAdd, Permissions.PropertyEdit); + if (propertyActivity.PropMgmtActivityStatusTypeCode == null) + { + propertyActivity.PropMgmtActivityStatusTypeCode = "NOTSTARTED"; + } + var propertyActivityResult = _propertyActivityRepository.Create(propertyActivity); _propertyActivityRepository.CommitTransaction(); diff --git a/source/backend/tests/unit/api/Services/PropertyServiceTest.cs b/source/backend/tests/unit/api/Services/PropertyServiceTest.cs index 4af1688de8..f2cd6609fd 100644 --- a/source/backend/tests/unit/api/Services/PropertyServiceTest.cs +++ b/source/backend/tests/unit/api/Services/PropertyServiceTest.cs @@ -297,6 +297,37 @@ public void Update_PropertyManagement_NoPermission() repository.Verify(x => x.UpdatePropertyManagement(It.IsAny()), Times.Never); } + [Fact] + public void Create_PropertyManagementActivity_NoPermission() + { + // Arrange + var service = this.CreatePropertyServiceWithPermissions(); + var repository = this._helper.GetService>(); + + // Act + Action act = () => service.CreateActivity(new PimsPropertyActivity()); + + // Assert + act.Should().Throw(); + repository.Verify(x => x.Create(It.IsAny()), Times.Never); + } + + [Fact] + public void Create_PropertyManagementActivity_Success() + { + // Arrange + var service = this.CreatePropertyServiceWithPermissions(Permissions.ManagementAdd, Permissions.PropertyEdit); + var repository = this._helper.GetService>(); + var activity = new PimsPropertyActivity(); + + // Act + var result = service.CreateActivity(activity); + + // Assert + activity.PropMgmtActivityStatusTypeCode.Should().Be("NOTSTARTED"); + repository.Verify(x => x.Create(It.IsAny()), Times.Once); + } + [Fact] public void Get_PropertyManagement_Activities_NoPermission() diff --git a/source/frontend/src/features/mapSideBar/property/tabs/propertyDetailsManagement/activity/edit/PropertyActivityEditForm.tsx b/source/frontend/src/features/mapSideBar/property/tabs/propertyDetailsManagement/activity/edit/PropertyActivityEditForm.tsx index 08b050be0e..73b356736e 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/propertyDetailsManagement/activity/edit/PropertyActivityEditForm.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/propertyDetailsManagement/activity/edit/PropertyActivityEditForm.tsx @@ -131,7 +131,7 @@ export const PropertyActivityEditForm: React.FunctionComponent< placeholder="Select subtype" /> - +