public async Task <ActionResult> UpdateAction(Guid id, EndpointActionDto actionDto) { var actn = await _endpointRuleRepository.FindAction(actionDto.Id.Value); _mapper.Map(actionDto, actn); UpdateAction(actn); await _endpointRuleRepository.UpdateActionAsync(actn); //await _endpointRuleRepository.AddActionToRule(entity); return(Ok()); }
public static EndpointActionEntity ToEntity(this EndpointActionDto dto) { var entity = new EndpointActionEntity(); entity.Id = dto.Id ?? Guid.Empty; entity.Order = dto.Order; entity.Enabled = dto.Enabled; entity.ActionType = dto.ActionType; entity.EndpointRuleEntityId = dto.EndpointRuleEntityId; entity.Terminating = dto.Terminating; entity.WriteStreamDirect = dto.WriteStreamDirect; entity.Parameters = Converter.Json.ToJObject(dto.Parameters); return(entity); }
public static EndpointActionDto ToEndpointRuleDto(this EndpointActionEntity entity, InternalHelper internalHelper) { var actionType = internalHelper.GetConcreteActionType(entity.ActionType); var optionsType = actionType.BaseType.GetGenericArguments().FirstOrDefault(); var dto = new EndpointActionDto(); dto.Id = entity.Id; dto.ActionType = entity.ActionType; dto.Enabled = entity.Enabled; dto.EndpointRuleEntityId = entity.EndpointRuleEntityId; dto.Order = entity.Order; dto.Terminating = entity.Terminating; dto.WriteStreamDirect = entity.WriteStreamDirect; var tempDict = Json.Converter.ToDictionary(entity.Parameters); var nDict = new Dictionary <string, object>(); foreach (var(key, value) in tempDict) { var prop = optionsType.GetProperty(key); if (prop == null) { continue; } var internalProp = prop.GetCustomAttribute <InternalAttribute>(); if (internalProp == null) { nDict.Add(key, value); } } dto.Parameters = nDict; return(dto); }