コード例 #1
0
        public ActionResult <GetResult> Get()
        {
            var styles = new List <Style>
            {
                new Style {
                    InputType = InputType.Text
                }
            };

            return(new GetResult
            {
                InputTypes = InputTypeUtils.GetInputTypes(),
                Styles = styles
            });
        }
コード例 #2
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request)
        {
            var relatedIdentities = ListUtils.GetIntList(request.RelatedIdentities);
            var style             = await _tableStyleRepository.GetTableStyleAsync(request.TableName, request.AttributeName, relatedIdentities) ?? new Models.TableStyle
            {
                InputType = InputType.Text
            };

            if (style.Items == null)
            {
                style.Items = new List <InputStyleItem>();
            }

            var isRapid     = true;
            var rapidValues = string.Empty;

            if (style.Items.Count == 0)
            {
                style.Items.Add(new InputStyleItem
                {
                    Label    = string.Empty,
                    Value    = string.Empty,
                    Selected = false
                });
            }
            else
            {
                var isSelected  = false;
                var isNotEquals = false;
                var list        = new List <string>();
                foreach (var item in style.Items)
                {
                    list.Add(item.Value);
                    if (item.Selected)
                    {
                        isSelected = true;
                    }
                    if (item.Value != item.Label)
                    {
                        isNotEquals = true;
                    }
                }

                isRapid     = !isSelected && !isNotEquals;
                rapidValues = ListUtils.ToStringByReturnAndNewline(list);
            }

            var form = new SubmitRequest
            {
                TableName         = style.TableName,
                AttributeName     = style.AttributeName,
                RelatedIdentities = request.RelatedIdentities,
                IsRapid           = isRapid,
                RapidValues       = rapidValues,
                Taxis             = style.Taxis,
                DisplayName       = style.DisplayName,
                HelpText          = style.HelpText,
                InputType         = style.InputType,
                DefaultValue      = style.DefaultValue,
                Horizontal        = style.Horizontal,
                Items             = style.Items,
                Height            = style.Height,
                CustomizeLeft     = style.CustomizeLeft,
                CustomizeRight    = style.CustomizeRight
            };

            return(new GetResult
            {
                InputTypes = InputTypeUtils.GetInputTypes(),
                Form = form
            });
        }
コード例 #3
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = new RequestImpl();
                if (!request.IsAdminLoggin)
                {
                    return(Unauthorized());
                }

                var tableName         = request.GetQueryString("tableName");
                var attributeName     = request.GetQueryString("attributeName");
                var relatedIdentities = TranslateUtils.StringCollectionToIntList(request.GetQueryString("relatedIdentities"));

                var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, attributeName, relatedIdentities) ?? new TableStyleInfo
                {
                    InputType = InputType.Text
                };
                if (styleInfo.StyleItems == null)
                {
                    styleInfo.StyleItems = new List <TableStyleItemInfo>();
                }

                var isRapid     = true;
                var rapidValues = string.Empty;
                if (styleInfo.StyleItems.Count == 0)
                {
                    styleInfo.StyleItems.Add(new TableStyleItemInfo
                    {
                        ItemTitle  = string.Empty,
                        ItemValue  = string.Empty,
                        IsSelected = false
                    });
                }
                else
                {
                    var isSelected  = false;
                    var isNotEquals = false;
                    var list        = new List <string>();
                    foreach (var item in styleInfo.StyleItems)
                    {
                        list.Add(item.ItemValue);
                        if (item.IsSelected)
                        {
                            isSelected = true;
                        }
                        if (item.ItemValue != item.ItemTitle)
                        {
                            isNotEquals = true;
                        }
                    }

                    isRapid     = !isSelected && !isNotEquals;
                    rapidValues = string.Join(",", list);
                }

                return(Ok(new
                {
                    Value = styleInfo,
                    InputTypes = InputTypeUtils.GetInputTypes(tableName),
                    IsRapid = isRapid,
                    RapidValues = rapidValues
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }