public void PutServiceAndChannel_DeleteConnections() { // Arrange var serviceId = Guid.NewGuid(); var channelId = Guid.NewGuid(); var request = new V7VmOpenApiServiceAndChannelRelationInBase() { DeleteAllChannelRelations = true }; serviceServiceMockSetup.Setup(s => s.ServiceExists(serviceId)).Returns(true); serviceServiceMockSetup.Setup(s => s.GetServiceByIdSimple(serviceId, true)) .Returns(new VmOpenApiServiceVersionBase() { PublishingStatus = PublishingStatus.Published.ToString() }); channelServiceMockSetup.Setup(s => s.GetServiceChannelByIdSimple(channelId, true)) .Returns(new VmOpenApiServiceChannel() { Id = channelId, IsVisibleForAll = true, ServiceChannelType = ServiceChannelTypeEnum.ServiceLocation.ToString() }); serviceAndChannelServiceMockSetup.Setup(s => s.SaveServiceConnections(It.IsAny <V7VmOpenApiServiceAndChannelRelationAstiInBase>(), defaultVersion)) .Returns(new VmOpenApiServiceVersionBase()); var controller = new V7ConnectionController(serviceAndChannelServiceMockSetup.Object, serviceServiceMockSetup.Object, channelServiceMockSetup.Object, userService, settings, logger); // Act var result = controller.PutServiceAndChannel(serviceId.ToString(), request); // Assert var okResult = Assert.IsType <OkObjectResult>(result); Assert.IsAssignableFrom <VmOpenApiServiceVersionBase>(okResult.Value); }
/// <summary> /// Update service and channel relationships. This is for regular connections. /// </summary> /// <param name="serviceId"></param> /// <param name="request"></param> /// <returns></returns> protected virtual IActionResult PutServiceAndChannelBase(string serviceId, V7VmOpenApiServiceAndChannelRelationInBase request) { if (request == null) { ModelState.AddModelError("RequestIsNull", CoreMessages.OpenApi.RequestIsNull); return(new BadRequestObjectResult(ModelState)); } return(PutServiceAndChannelByService(serviceId, request.ConvertToLatestVersion())); }
public IActionResult PutServiceAndChannel(string serviceId, [FromBody] V7VmOpenApiServiceAndChannelRelationInBase request) { return(PutServiceAndChannelBase(serviceId, request)); }