Esempio n. 1
0
        public override async Task <BaseReply> AddColumn(AddColumnRequest request, ServerCallContext context)
        {
            try
            {
                var field = new Dto.Field
                {
                    Name       = request.ColumnName,
                    Type       = (SupportedTypes)request.DataValueType,
                    Validators = _grpcModelMapper.GetValidatorsDtoFromGrpcValidators(request.Validators)
                };

                await _tableDal.AddField(request.TableName, request.DbName, field);

                var response = new BaseReply()
                {
                    Code = 200
                };

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("***************************************************************************************************************");
                Console.WriteLine("Column added: " + request.TableName + ", " + request.ColumnName);
                Console.WriteLine("***************************************************************************************************************");

                return(response);
            }
            catch (Exception ex)
            {
                return(new BaseReply()
                {
                    Code = 400, Message = ex.Message, StackTrace = ex.StackTrace
                });
            }
        }
        public void AddField(string dbName, string tableName, string fieldName, SupportedTypes type, List <IValidator> validators)
        {
            var url = RequestBuilder.StartBuild(_settings.Host)
                      .AddUrl(_settings.Constants.TableController, dbName,
                              tableName, _settings.Endpoints.AddField)
                      .Build();

            var field = new Dto.Field
            {
                Name       = fieldName,
                Type       = type,
                Validators = _mapper.GetDtoValidators(validators)
            };

            PostRequest(url, field);
        }