public async Task UpdateEntityTypeAsync2()
        {
            Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new Mock <EntityTypes.EntityTypesClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            UpdateEntityTypeRequest expectedRequest = new UpdateEntityTypeRequest
            {
                EntityType   = new EntityType(),
                LanguageCode = "languageCode-412800396",
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
                DisplayName    = "displayName1615086568",
            };

            mockGrpcClient.Setup(x => x.UpdateEntityTypeAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <EntityType>(Task.FromResult(expectedResponse), null, null, null, null));
            EntityTypesClient client       = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityType        entityType   = new EntityType();
            string            languageCode = "languageCode-412800396";
            EntityType        response     = await client.UpdateEntityTypeAsync(entityType, languageCode);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async stt::Task UpdateEntityTypeAsync()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            UpdateEntityTypeRequest request = new UpdateEntityTypeRequest
            {
                EntityType = new EntityType(),
                UpdateMask = new wkt::FieldMask(),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName    = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                DisplayName       = "display_name137f65c2",
                Kind              = EntityType.Types.Kind.Regexp,
                AutoExpansionMode = EntityType.Types.AutoExpansionMode.Default,
                Entities          =
                {
                    new EntityType.Types.Entity(),
                },
                ExcludedPhrases =
                {
                    new EntityType.Types.ExcludedPhrase(),
                },
                EnableFuzzyExtraction = false,
            };

            mockGrpcClient.Setup(x => x.UpdateEntityTypeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <EntityType>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            EntityTypesClient client = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityType        responseCallSettings = await client.UpdateEntityTypeAsync(request.EntityType, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            EntityType responseCancellationToken = await client.UpdateEntityTypeAsync(request.EntityType, request.UpdateMask, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void UpdateEntityType()
        {
            Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new Mock <EntityTypes.EntityTypesClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            UpdateEntityTypeRequest expectedRequest = new UpdateEntityTypeRequest
            {
                EntityType = new EntityType(),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName = new EntityTypeName("[PROJECT]", "[ENTITY_TYPE]"),
                DisplayName    = "displayName1615086568",
            };

            mockGrpcClient.Setup(x => x.UpdateEntityType(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            EntityTypesClient client     = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityType        entityType = new EntityType();
            EntityType        response   = client.UpdateEntityType(entityType);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #4
0
        public void UpdateEntityType()
        {
            moq::Mock <EntityTypes.EntityTypesClient> mockGrpcClient = new moq::Mock <EntityTypes.EntityTypesClient>(moq::MockBehavior.Strict);
            UpdateEntityTypeRequest request = new UpdateEntityTypeRequest
            {
                EntityType = new EntityType(),
                UpdateMask = new wkt::FieldMask(),
            };
            EntityType expectedResponse = new EntityType
            {
                EntityTypeName    = EntityTypeName.FromProjectLocationAgentEntityType("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENTITY_TYPE]"),
                DisplayName       = "display_name137f65c2",
                Kind              = EntityType.Types.Kind.Regexp,
                AutoExpansionMode = EntityType.Types.AutoExpansionMode.Default,
                Entities          =
                {
                    new EntityType.Types.Entity(),
                },
                ExcludedPhrases =
                {
                    new EntityType.Types.ExcludedPhrase(),
                },
                EnableFuzzyExtraction = false,
            };

            mockGrpcClient.Setup(x => x.UpdateEntityType(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EntityTypesClient client   = new EntityTypesClientImpl(mockGrpcClient.Object, null);
            EntityType        response = client.UpdateEntityType(request.EntityType, request.UpdateMask);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task <ActionResult> Edit(Guid id, EditEntityTypeViewModel request)
        {
            if (!ModelState.IsValid)
            {
                Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            if (!id.Equals(request.Id))
            {
                Alert("Invalid Request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
            try
            {
                var tierUpdateRequest = new UpdateEntityTypeRequest {
                    Id = request.Id, Name = request.Name, Description = request.Description
                };
                var result = await _entityTypeService.Update(id, tierUpdateRequest);

                if (!result.Success)
                {
                    Alert($"Error: {result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View());
                }

                Alert($"Tier Updated Successfully", NotificationType.success, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                Alert($"Error Occurred While processing the request", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View());
            }
        }
 /// <summary>Snippet for UpdateEntityType</summary>
 public void UpdateEntityTypeRequestObject()
 {
     // Snippet: UpdateEntityType(UpdateEntityTypeRequest, CallSettings)
     // Create client
     EntityTypesClient entityTypesClient = EntityTypesClient.Create();
     // Initialize request argument(s)
     UpdateEntityTypeRequest request = new UpdateEntityTypeRequest
     {
         EntityType   = new EntityType(),
         LanguageCode = "",
         UpdateMask   = new FieldMask(),
     };
     // Make the request
     EntityType response = entityTypesClient.UpdateEntityType(request);
     // End snippet
 }
        /// <summary>Snippet for UpdateEntityTypeAsync</summary>
        public async Task UpdateEntityTypeRequestObjectAsync()
        {
            // Snippet: UpdateEntityTypeAsync(UpdateEntityTypeRequest, CallSettings)
            // Additional: UpdateEntityTypeAsync(UpdateEntityTypeRequest, CancellationToken)
            // Create client
            EntityTypesClient entityTypesClient = await EntityTypesClient.CreateAsync();

            // Initialize request argument(s)
            UpdateEntityTypeRequest request = new UpdateEntityTypeRequest
            {
                EntityType   = new EntityType(),
                LanguageCode = "",
                UpdateMask   = new FieldMask(),
            };
            // Make the request
            EntityType response = await entityTypesClient.UpdateEntityTypeAsync(request);

            // End snippet
        }
Beispiel #8
0
        public async Task <ServiceResponse <EntityType> > Update(Guid id, UpdateEntityTypeRequest request)
        {
            try
            {
                var result = await _baseRepository.GetById(id);

                if (result == null)
                {
                    return(new ServiceResponse <EntityType>($"The requested Tier could not be found"));
                }

                result.Name        = request.Name;
                result.Description = request.Description;
                result.LastUpdated = DateTime.Now;

                await _baseRepository.Update(id, result);

                return(new ServiceResponse <EntityType>(result));
            }
            catch (Exception ex)
            {
                return(new ServiceResponse <EntityType>($"An Error Occured While Updating The Entity Type. {ex.Message}"));
            }
        }