/// <inheritdoc />
 public CreateFieldRequest(int projectId,
                           ProjectFieldType fieldType,
                           string name,
                           string fieldHint,
                           bool canPlayerEdit,
                           bool canPlayerView,
                           bool isPublic,
                           FieldBoundTo fieldBoundTo,
                           MandatoryStatus mandatoryStatus,
                           IReadOnlyCollection <int> showForGroups,
                           bool validForNpc,
                           bool includeInPrint,
                           bool showForUnapprovedClaims,
                           int price,
                           string masterFieldHint,
                           string programmaticValue) : base(projectId,
                                                            name,
                                                            fieldHint,
                                                            canPlayerEdit,
                                                            canPlayerView,
                                                            isPublic,
                                                            mandatoryStatus,
                                                            showForGroups,
                                                            validForNpc,
                                                            includeInPrint,
                                                            showForUnapprovedClaims,
                                                            price,
                                                            masterFieldHint,
                                                            programmaticValue)
 {
     FieldType    = fieldType;
     FieldBoundTo = fieldBoundTo;
 }
Example #2
0
        public async Task AddField(int projectId, ProjectFieldType fieldType, string name, string fieldHint, bool canPlayerEdit, bool canPlayerView, bool isPublic, FieldBoundTo fieldBoundTo, MandatoryStatus mandatoryStatus, List <int> showForGroups, bool validForNpc, bool includeInPrint, bool showForUnapprovedClaims)
        {
            var project = await ProjectRepository.GetProjectAsync(projectId);

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

            var field = new ProjectField
            {
                FieldName       = Required(name),
                Description     = new MarkdownString(fieldHint),
                CanPlayerEdit   = canPlayerEdit,
                CanPlayerView   = canPlayerView,
                ValidForNpc     = validForNpc,
                IsPublic        = isPublic,
                ProjectId       = projectId,
                Project         = project, //We require it for CreateOrUpdateSpecailGroup
                FieldType       = fieldType,
                FieldBoundTo    = fieldBoundTo,
                IsActive        = true,
                MandatoryStatus = mandatoryStatus,
                AvailableForCharacterGroupIds = await ValidateCharacterGroupList(projectId, showForGroups),
                IncludeInPrint         = includeInPrint,
                ShowOnUnApprovedClaims = showForUnapprovedClaims
            };


            CreateOrUpdateSpecialGroup(field);

            UnitOfWork.GetDbSet <ProjectField>().Add(field);
            await UnitOfWork.SaveChangesAsync();
        }