public async Task <HttpResponseMessage> SaveColumnsSettingsAsync( int id, [FromBody] ProfileColumnsDto profileColumnsDto) { if (profileColumnsDto == null || profileColumnsDto.Items.IsEmpty()) { throw new BadRequestException( ErrorMessages.Collections.ColumnsSettingsModelIsIncorrect, ErrorCodes.BadRequest); } var profileColumns = new ProfileColumns(profileColumnsDto.Items); var customPropertiesChanged = await _collectionsService.SaveProfileColumnsAsync(id, profileColumns, Session.UserId); return(customPropertiesChanged ? Request.CreateResponse(HttpStatusCode.OK, ErrorMessages.ArtifactList.ColumnsSettings.ChangedCustomProperties) : Request.CreateResponse(HttpStatusCode.NoContent)); }
public void Initialize() { _userId = 1; _session = new Session { UserId = _userId }; _pagination = new Pagination { Limit = int.MaxValue, Offset = 0 }; _collectionsServiceMock = new Mock <ICollectionsService>(); _artifactListServiceMock = new Mock <IArtifactListService>(); _collectionsController = new CollectionsController( _collectionsServiceMock.Object, _artifactListServiceMock.Object) { Request = new HttpRequestMessage() }; _collectionsController.Request.Properties[ServiceConstants.SessionProperty] = _session; _artifactIds = new HashSet <int> { 1, 2, 3 }; _collectionId = 1; _addArtifactsResult = new AddArtifactsToCollectionResult { AddedCount = 1, Total = 1 }; _removeArtifactsFromCollectionResult = new RemoveArtifactsFromCollectionResult { RemovedCount = 1, Total = 3 }; _profileColumnsDto = new ProfileColumnsDto { Items = new List <ProfileColumn> { new ProfileColumn("Custom", PropertyTypePredefined.CustomGroup, PropertyPrimitiveType.Text, 2) } }; _expectedCollectionArtifacts = new CollectionArtifacts { ItemsCount = 2, ArtifactListSettings = new ArtifactListSettings { Columns = new List <ProfileColumn> { new ProfileColumn { Predefined = PropertyTypePredefined.Name, PrimitiveType = PropertyPrimitiveType.Text, PropertyName = "Name", PropertyTypeId = 80 }, new ProfileColumn { Predefined = PropertyTypePredefined.Description, PrimitiveType = PropertyPrimitiveType.Text, PropertyName = "Description", PropertyTypeId = 81 } }, Filters = new List <ArtifactListFilter>() }, Items = new List <ArtifactDto> { new ArtifactDto { ArtifactId = 7545, ItemTypeId = 134, PredefinedType = 4107, PropertyInfos = new List <PropertyValueInfo> { new PropertyValueInfo { PropertyTypeId = 80, Value = "Value_Name" }, new PropertyValueInfo { PropertyTypeId = 81, Value = "Value_Description", IsRichText = true } } }, new ArtifactDto { ArtifactId = 7551, ItemTypeId = 132, PredefinedType = 4105, PropertyInfos = new List <PropertyValueInfo> { new PropertyValueInfo { PropertyTypeId = 80, Value = "Value_Name_2" }, new PropertyValueInfo { PropertyTypeId = 81, Value = "Value_Description_2", IsRichText = true } } } } }; _columns = new GetColumnsDto { SelectedColumns = new List <ProfileColumn> { new ProfileColumn("Custom", PropertyTypePredefined.Name, PropertyPrimitiveType.Number, 3) }, UnselectedColumns = new List <ProfileColumn> { new ProfileColumn("Custom", PropertyTypePredefined.Name, PropertyPrimitiveType.Number, 3) } }; }