/// <summary> /// Get service by service channel base. /// </summary> /// <param name="serviceChannelId"></param> /// <param name="date"></param> /// <returns></returns> protected virtual IActionResult GetByServiceChannelBase(string serviceChannelId, [FromQuery] DateTime?date) { Guid guid = serviceChannelId.ParseToGuidWithExeption(); if (!channelService.ChannelExists(guid)) { return(NotFound(new VmError() { ErrorMessage = $"Service channel with id '{serviceChannelId}' not found." })); } return(Ok(serviceService.GetServicesByServiceChannel(guid, date, versionNumber))); }
/// <summary> /// Update channel and service relationships. This is for ASTI connections. /// </summary> /// <param name="serviceChannelId"></param> /// <param name="request"></param> /// <returns></returns> protected virtual IActionResult PutChannelServices(string serviceChannelId, V7VmOpenApiChannelServicesIn request) { if (request == null) { ModelState.AddModelError("RequestIsNull", CoreMessages.OpenApi.RequestIsNull); return(new BadRequestObjectResult(ModelState)); } // Validate the items if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } if (!string.IsNullOrEmpty(serviceChannelId)) { request.ChannelId = serviceChannelId.ParseToGuid(); // check that channel exists if (!request.ChannelId.HasValue || !channelService.ChannelExists(request.ChannelId.Value)) { return(NotFound(new VmError() { ErrorMessage = $"Service channel with id '{serviceChannelId}' not found." })); } } else { return(NotFound(new VmError() { ErrorMessage = $"Service channel id has to be set." })); } request.ServiceRelations.ForEach(r => { r.ChannelGuid = request.ChannelId.Value; r.ServiceGuid = r.ServiceId.ParseToGuidWithExeption(); r.ExtraTypes.ForEach(e => { e.ServiceGuid = r.ServiceGuid; e.ChannelGuid = r.ChannelGuid; }); r.IsASTIConnection = true; }); // Validate channel and services connections. // Validate channel for channel type (only service location channel can include additional connection information - PTV-2475) // Validate service ids. var channelValidator = new ServiceChannelConnectionListValidator(request.ServiceRelations, channelService, serviceService); channelValidator.Validate(this.ModelState); // Validate the items if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } var srv = serviceAndChannelService.SaveServiceChannelConnections(request, versionNumber); if (srv == null) { return(NotFound(new VmError() { ErrorMessage = $"Service channel with id '{serviceChannelId}' not found." })); } return(Ok(srv)); }