public async Task ServerTest()
        {
            var req = FieldRequest.CreateFields();

            req = req.Append(CreateFieldRequest.Builder().With(ResourceId.Activity, FieldType.Number, "test").Build().Content);

            var built = ((CreateFieldsRequest.IBuilderWithRecord)req).Build();

            IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings {
                ServerUrl = new Uri("http://namtest3-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory
            });

            using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password")))
            {
                var fields = await session.CallAsync(built);

                Assume.That(fields.FieldFailed, Has.Count.EqualTo(0));
                Assume.That(fields.FieldSuccess, Has.Count.GreaterThan(0));
                var mapping = fields.FieldSuccess.ToDictionary(entry => entry.Value, entry => entry.Key);

                var res = await session.CallAsync(FieldRequest.GetFields().Select(FieldProperty.Name).WhereGuid(fields.FieldSuccess.Values));

                var conv = res
                           .ToDictionary(fieldEntry => mapping[(Guid)fieldEntry.Value[FieldProperty.Id]], fieldEntry => fieldEntry.Value);
                Assert.That(res, Has.Count.GreaterThan(0));
            }
        }
예제 #2
0
        public async Task AddField(CreateFieldRequest request)
        {
            var project = await ProjectRepository.GetProjectAsync(request.ProjectId);

            _ = project.RequestMasterAccess(CurrentUserId, acl => acl.CanChangeFields);

            if (project.GetTimeSlotFieldOrDefault() != null && request.FieldType == ProjectFieldType.ScheduleTimeSlotField)
            {
                throw new JoinFieldScheduleShouldBeUniqueException(project);
            }

            if (project.GetRoomFieldOrDefault() != null && request.FieldType == ProjectFieldType.ScheduleRoomField)
            {
                throw new JoinFieldScheduleShouldBeUniqueException(project);
            }

            var field = new ProjectField
            {
                ProjectId    = request.ProjectId,
                Project      = project,
                FieldType    = request.FieldType,
                FieldBoundTo = request.FieldBoundTo,
            };

            await SetFieldPropertiesFromRequest(request, field);

            project.ProjectFields.Add(field);

            SetScheduleStatusBasedOnFields(project);

            _ = UnitOfWork.GetDbSet <ProjectField>().Add(field);
            await UnitOfWork.SaveChangesAsync();
        }
예제 #3
0
        public async Task <CustomTabFieldResponseDto> AddCustomTemplateTabFields(CreateFieldRequest createCustomTabFieldRequest)
        {
            var field = new Domain.CustomEntity.CustomField
            {
                Id             = createCustomTabFieldRequest.Id,
                FieldName      = createCustomTabFieldRequest.Caption,
                CustomTabId    = createCustomTabFieldRequest.TabId,
                IsMandatory    = createCustomTabFieldRequest.IsRequired,
                IsVisible      = createCustomTabFieldRequest.IsVisible,
                FieldTypeId    = createCustomTabFieldRequest.ControlTypeId,
                CustomEntityId = createCustomTabFieldRequest.TemplateId,
                IsArchived     = false,
                IsDeleted      = false,
                AddedBy        = 1,
                AddedDate      = DateTime.UtcNow
            };
            var response = await _customFieldRepository.AddAsync(field);

            return(response.Id != default(int) ? new CustomTabFieldResponseDto
            {
                Id = response.Id,
                Caption = response.FieldName,
                TabId = response.CustomTabId.GetValueOrDefault(),
                IsRequired = response.IsMandatory.GetValueOrDefault(),
                TabName = response.CustomTab.Name,
                SortOrder = response.SortOrder ?? 1,
                ControlType = response.FieldType.Caption,
                Key = $"field_{response.Id}",
            } : null);
        }
        private void InitFieldCreator()
        {
            var    fieldRequestBuilder = FieldRequest.CreateFields();
            string mimeType            = "image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp";

            foreach (var resourceId in Enum.GetValues(typeof(Enums.ResourceType)).Cast <Enums.ResourceType>())
            {
                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Required(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Required}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Required(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoRequired}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Searchable(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Searchable}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Searchable(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{UnSearchable}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Web(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Web}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Web(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoWeb}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Highlight(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Document}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Highlight(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoDocument}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Copy(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Copy}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Copy(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoCopy}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field", "TEST")
                                           .MimeType(mimeType).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Annotation}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field", null)
                                           .MimeType(mimeType).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoAnnotation}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Height(100).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Height}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoHeight}");
            }

            var fieldRequest = ((CreateFieldsRequest.IBuilderWithRecord)fieldRequestBuilder).Build().Content;

            customFields = new HrbcFieldCreator(fieldRequest, new List <FieldProperty> {
                FieldProperty.Id, FieldProperty.Name, FieldProperty.Resource
            });
        }
예제 #5
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            foreach (var resource in Utils.Resources())
            {
                request.Append(CreateFieldRequest.Builder().With((ResourceId)resource, (HRBCClientPrivate.API.Field.FieldType)((int)(HRBCClientPrivate.API.Field.FieldType.SingleLineText)), $"{resource}_TestField").Build().Content, $"{resource}");
            }
            UserField = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Name, FieldProperty.Resource });
        }
예제 #6
0
        public static HrbcFieldCreator PrepareAttachmentField()
        {
            var request = FieldRequest.CreateFields();

            request.Append(CreateFieldRequest.Builder().With(ResourceId.Client, FieldType.File, $"{ResourceId.Client}_{FieldType.File}")
                           .DisplayType(DisplayType.SearchBoxMultiSelection)
                           .Height(50)
                           .MimeType("image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp").Build().Content, $"{ResourceId.Client}_{FieldType.File}");
            return(new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType }));
        }
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            foreach (var resource in Utils.Resources())
            {
                request.Append(CreateFieldRequest.Builder().With((ResourceId)resource, (FieldType)((int)(TestCoreFramework.Enums.FieldType.SingleLineText)), "Test Field").Build().Content, $"{resource.ToString()}");
            }
            FieldCreator      = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Name });
            FieldCreatorOther = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Name });
        }
예제 #8
0
        public ValidReportDataReadTests()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Utils.Resources())
            {
                request.Append(CreateFieldRequest.Builder().With((HRBCClientPrivate.Common.ResourceId)resource, (HRBCClientPrivate.API.Field.FieldType)((int)(TestCoreFramework.Enums.FieldType.SingleLineText)), "Test Field").Build().Content, $"{resource.ToString()}");
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id });
        }
예제 #9
0
        public IActionResult CreateCollection(CreateFieldRequest fieldRequest)
        {
            Field field = new Field
            {
                Name         = fieldRequest.Name,
                Type         = (FieldType)Enum.Parse(typeof(FieldType), fieldRequest.FieldType, true),
                CollectionId = fieldRequest.CollectionId
            };

            fieldService.Create(field);
            return(Ok());
        }
예제 #10
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
            {
                var fieldType = TestCoreFramework.Enums.FieldType.DateTime;
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, (HRBCClientPrivate.API.Field.FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}");
                }
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id });
        }
예제 #11
0
        public async Task <IActionResult> Post(CreateFieldRequest request)
        {
            if (OrganisationId == Guid.Empty)
            {
                return(Forbid());
            }
            var fieldDto = _mapper.Map <FieldDto>(request);

            fieldDto.OrganisationId = OrganisationId;
            var id = Guid.NewGuid();

            fieldDto.Id = id;
            await _fieldService.CreateAsync(fieldDto);

            return(Ok());
        }
예제 #12
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
            {
                foreach (var fieldType in SearchConstants.RequiredFieldTypes.Except(new[] { TestCoreFramework.Enums.FieldType.OptionCheckbox }))
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, (HRBCClientPrivate.API.Field.FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}");
                }
                request.Append(CreateFieldRequest.Builder().With(resource, HRBCClientPrivate.API.Field.FieldType.OptionCheckbox, $"{resource}_OptionCheckbox")
                               .OptionCount(0).OptionMaster("Option.P_ContructorType").DisplayType(DisplayType.CheckBox).Build().Content, $"{resource}_OptionCheckbox");
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id });
        }
예제 #13
0
        public async Task <ActionResult> Create(GameFieldCreateViewModel viewModel)
        {
            var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId);

            var error = AsMaster(project, pa => pa.CanChangeFields);

            if (error != null)
            {
                return(error);
            }
            if (!ModelState.IsValid)
            {
                return(View(FillFromProject(project, viewModel)));
            }
            try
            {
                var request = new CreateFieldRequest(
                    project.ProjectId,
                    (ProjectFieldType)viewModel.FieldViewType,
                    viewModel.Name,
                    viewModel.DescriptionEditable,
                    viewModel.CanPlayerEdit,
                    viewModel.CanPlayerView,
                    viewModel.IsPublic,
                    (FieldBoundTo)viewModel.FieldBoundTo,
                    (MandatoryStatus)viewModel.MandatoryStatus,
                    viewModel.ShowForGroups.GetUnprefixedGroups(),
                    viewModel.ValidForNpc,
                    viewModel.FieldBoundTo == FieldBoundToViewModel.Character && viewModel.CanPlayerView,
                    viewModel.ShowForUnApprovedClaim,
                    viewModel.Price,
                    viewModel.MasterDescriptionEditable,
                    programmaticValue: null);

                await FieldSetupService.AddField(request);

                return(ReturnToIndex(project));
            }
            catch (Exception exception)
            {
                ModelState.AddException(exception);
                return(View(FillFromProject(project, viewModel)));
            }
        }
예제 #14
0
        protected string CreateNewField(ISession <PrivateAuthentication> session, Enums.ResourceType type, string label = null)
        {
            if (null == label)
            {
                label = "My test field";
            }
            var request = CreateFieldRequest.Builder()
                          .With(type.ToString().ToResourceId(), FieldType.Date, label)
                          //.JapaneseLabel(label)
                          //.JapaneseCaption("Date field")
                          .DefaultValue("2016/09/24")
                          .Required(false)
                          .Searchable(true)
                          .Web(false)
                          .Highlight(false);
            var id = session.Call(request.Build());

            return(id.ToString());
        }
예제 #15
0
        public async Task AddField(CreateFieldRequest request)
        {
            var project = await ProjectRepository.GetProjectAsync(request.ProjectId);

            project.RequestMasterAccess(CurrentUserId, acl => acl.CanChangeFields);

            var field = new ProjectField
            {
                ProjectId    = request.ProjectId,
                Project      = project,
                FieldType    = request.FieldType,
                FieldBoundTo = request.FieldBoundTo,
            };

            await SetFieldPropertiesFromRequest(request, field);

            UnitOfWork.GetDbSet <ProjectField>().Add(field);
            await UnitOfWork.SaveChangesAsync();
        }
예제 #16
0
        public static CreateFieldsRequest PrepareReferenceFields(Func <ResourceId, Dictionary <string, ulong> > targetFieldsProvider)
        {
            var request = FieldRequest.CreateFields();

            foreach (var masterResource in CommonConstants.ResourceToPossibleReferenceResourcesMap)
            {
                foreach (var dependentResource in masterResource.Value)
                {
                    foreach (var targetField in targetFieldsProvider(dependentResource))
                    {
                        request.Append(CreateFieldRequest.Builder().With(masterResource.Key, FieldType.Reference, $"{masterResource.Key}_{dependentResource}.{targetField.Key}")
                                       .Searchable(true)
                                       .Name($"{(int)dependentResource}{targetField.Key.Replace("_","")}")
                                       .LinkedField(targetField.Value.ToString()).Build().Content, new ReferenceInfo(masterResource.Key, dependentResource, targetField.Key, targetField.Value));
                    }
                }
            }
            return(((CreateFieldsRequest.IBuilderWithRecord)request).Build().Content);
        }
예제 #17
0
        public void TestCreateFieldWithBuilderAsync()
        {
            var request = CreateFieldRequest.Builder()
                          .Resource(ResourceId.Job)
                          .Required(false)
                          .FieldType(FieldType.Date)
                          .DefaultValue(DateTime.Now.ToString("yyyy/MM/dd"))
                          .Searchable(false)
                          .JapaneseLabel("This a date field")
                          .JapaneseCaption("This is a date field");
            Task <IdModel> result = session.CallAsync(request.GetRequest());

            TestContext.Out.WriteLine("Take a cup of coffee in meantime!");
            IdModel response = result.Result;

            TestContext.Out.WriteLine("Start to get the result !");
            Assert.That(response, Is.Not.Null, "Response data is null!");
            Assert.That(string.IsNullOrEmpty(response.Id), Is.False, "Id is null!");
            TestContext.Out.WriteLine(string.Format("Id: {0}", response.Id));
            fieldIdList.Add(response.Id);
        }
예제 #18
0
        public async Task SimpleInputCreatesField()
        {
            Guid expectedId = HRBCClientPrivate.Util.UuidUtil.BuildFieldGuid(101, 303, ResourceId.Client);

            var expectedResponse = "{'id':'" + expectedId.ToString() + "'}";
            var expectedRequest  = @"{""create"":{""dataType"":""number"",""resource"":""client"",""properties"":{""s.type"":3,""d.label.ja"":""test"",""d.caption.ja"":""""}}}";
            var mocker           = HrbcVersion.Trunk.ToRequestMocker();

            mocker.WhenRequest(HttpRequestConstraint.HttpRequest()
                               .WithMethod(HttpMethod.Post)
                               .WithUri("field/field")
                               .WithContent(expectedRequest))
            .RespondWith(expectedResponse);

            using (var session = mocker.Session)
            {
                var id = await session.CallAsync(CreateFieldRequest.Builder().With(ResourceId.Client, FieldType.Number, "test"));

                Assert.That(id, Is.EqualTo(expectedId));
            }
        }
예제 #19
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
            {
                foreach (var fieldType in FieldTypeToTest.Except(new[] { TestCoreFramework.Enums.FieldType.File }))
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, (HRBCClientPrivate.API.Field.FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}");
                }
                foreach (var imageType in ImageFileTypes)
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, HRBCClientPrivate.API.Field.FieldType.File, $"{resource}_File_{imageType}")
                                   .DisplayType(DisplayType.SearchBoxMultiSelection)
                                   .Height(50)
                                   .MimeType("image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp").Build().Content, $"{resource}_File_{imageType}");
                }
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType });
        }
예제 #20
0
        public static HrbcFieldCreator PrepareFields(int num)
        {
            var   request      = FieldRequest.CreateFields();
            ulong OptionMaster = 29;

            foreach (var resource in Resources)
            {
                for (var i = 0; i < num; i++)
                {
                    foreach (var fieldType in FieldTypeToTest.Except(new[] { FieldType.File, FieldType.Option }))
                    {
                        request.Append(CreateFieldRequest.Builder().With(resource, (FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}_{i}");
                    }
                    request.Append(CreateFieldRequest.Builder().With(resource, FieldType.File, $"{resource}_{FieldType.File}")
                                   .DisplayType(DisplayType.SearchBoxMultiSelection)
                                   .Height(50)
                                   .MimeType("image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp").Build().Content, $"{resource}_{FieldType.File}_{i}");
                    request.Append(resource, FieldType.Option, $"{FieldType.Option}",
                                   content => content.Searchable(true).Copy(false).Required(false).OptionCount(0).DisplayType(DisplayType.CheckBox).OptionMaster(OptionMaster), $"{resource}_{FieldType.Option}_{i}");
                }
            }
            return(new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType }));
        }
        private CreateFieldsRequest PrepareReferenceFields()
        {
            var request = FieldRequest.CreateFields();

            foreach (var masterResource in ResourceToPossibleReferenceResourcesMap)
            {
                foreach (var dependentResource in masterResource.Value)
                {
                    foreach (var dependentField in FieldReader.Data.Where(pair => pair.Key.Resource == dependentResource))
                    {
                        request.Append(CreateFieldRequest.Builder().With(masterResource.Key, FieldType.Reference, $"{masterResource.Key}_{dependentField.Key.ToAlias()}")
                                       .Searchable(true)
                                       .LinkedField(UuidUtil.GetId(Guid.Parse(dependentField.Value[FieldProperty.Id].ToString())).ToString()).Build().Content, new ReferenceInfo
                        {
                            MasterResource    = masterResource.Key,
                            DependentResource = dependentResource,
                            TargetFieldName   = dependentField.Key.Name,
                            TargetFieldType   = (TestCoreFramework.Enums.FieldType)Convert.ToInt32(dependentField.Value[FieldProperty.FieldType])
                        });
                    }

                    foreach (var createdField in ReferenceTargetFieldCreator.Data.Where(pair => (ResourceId)pair.Value[FieldProperty.Resource] == dependentResource))
                    {
                        request.Append(CreateFieldRequest.Builder().With(masterResource.Key, FieldType.Reference, $"{masterResource.Key}_{dependentResource}.{createdField.Value[FieldProperty.Name]}")
                                       .Searchable(true)
                                       .LinkedField(UuidUtil.GetId(Guid.Parse(createdField.Value[FieldProperty.Id].ToString())).ToString()).Build().Content, new ReferenceInfo
                        {
                            MasterResource    = masterResource.Key,
                            DependentResource = dependentResource,
                            TargetFieldName   = createdField.Value.Name,
                            TargetFieldType   = (TestCoreFramework.Enums.FieldType)Convert.ToInt32(createdField.Value[FieldProperty.FieldType])
                        });
                    }
                }
            }
            return(((CreateFieldsRequest.IBuilderWithRecord)request).Build().Content);
        }
예제 #22
0
        public void TestUpdateField()
        {
            //Create some date field.
            var request1 = CreateFieldRequest.Builder()
                           .Resource(ResourceId.Job)
                           .Required(false)
                           .FieldType(FieldType.Date)
                           .DefaultValue(DateTime.Now.ToString("yyyy/MM/dd"))
                           .Searchable(false)
                           .JapaneseLabel("This is the first date field")
                           .JapaneseCaption("This is the first date field");
            var request2 = request1.JapaneseCaption("This is the second date field")
                           .JapaneseCaption("This is the second date field");
            Task <IdModel> result1 = session.CallAsync(request1.GetRequest());
            Task <IdModel> result2 = session.CallAsync(request2.GetRequest());

            TestContext.Out.WriteLine("Take a cup of coffee in meantime and wait for all tasks completes!");
            Task.WaitAll(result1, result2);
            TestContext.Out.WriteLine("Start to get the result !");
            Assume.That(result1.Result, Is.Not.Null, "Response data is null!");
            Assume.That(string.IsNullOrEmpty(result1.Result.Id), Is.False, "Id is null!");
            Assume.That(result2.Result, Is.Not.Null, "Response data is null!");
            Assume.That(string.IsNullOrEmpty(result2.Result.Id), Is.False, "Id is null!");

            fieldIdList.Add(result1.Result.Id);
            fieldIdList.Add(result2.Result.Id);

            var updateRequest = UpdateFieldRequest.Builder()
                                .Add(result1.Result.Id, UpdateFieldRequest.SingleFieldBuilder().JapaneseCaption("This is the first EDITED date field")
                                     .JapaneseLabel("This is the first EDITED date field"))
                                .Add(result2.Result.Id, UpdateFieldRequest.SingleFieldBuilder().JapaneseCaption("This is the second edited date field")
                                     .JapaneseLabel("This is the second edited date field"));
            var updateTask = session.CallAsync(updateRequest.GetRequest());

            Assert.That(updateTask.Result, Is.True, "Updating is not successful!");
        }
예제 #23
0
        public async Task <ActionResult> Create(GameFieldCreateViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(await ViewIfFound(Manager.FillFailedModel(viewModel)));
            }
            try
            {
                var request = new CreateFieldRequest(
                    viewModel.ProjectId,
                    (ProjectFieldType)viewModel.FieldViewType,
                    viewModel.Name,
                    viewModel.DescriptionEditable,
                    viewModel.CanPlayerEdit,
                    viewModel.CanPlayerView,
                    viewModel.IsPublic,
                    (FieldBoundTo)viewModel.FieldBoundTo,
                    (MandatoryStatus)viewModel.MandatoryStatus,
                    viewModel.ShowForGroups.GetUnprefixedGroups(),
                    viewModel.ValidForNpc,
                    viewModel.FieldBoundTo == FieldBoundToViewModel.Character && viewModel.CanPlayerView,
                    viewModel.ShowForUnApprovedClaim,
                    viewModel.Price,
                    viewModel.MasterDescriptionEditable,
                    programmaticValue: null);

                await FieldSetupService.AddField(request);

                return(ReturnToIndex());
            }
            catch (Exception exception)
            {
                ModelState.AddException(exception);
                return(View(await Manager.FillFailedModel(viewModel)));
            }
        }
        public async Task <IActionResult> Post([FromBody] CreateFieldRequest createFieldRequest)
        {
            var response = await _customEntityManagementService.AddCustomTemplateTabFields(createFieldRequest);

            return(Ok(response));
        }
예제 #25
0
 protected static CreateFieldRequest FieldCreateRequestFromSpec(FieldSpec spec)
 {
     return(CreateFieldRequest.Builder().With((ResourceId)(int)spec.Resource, (FieldType)(int)spec.FieldType, spec.Label == null ? spec.Key.ToString() : spec.Label).Build().Content);
 }