コード例 #1
0
        public async Task <IActionResult> GetLookupFor(string model, string formType, string formName, string fieldName,
                                                       [FromBody] object filterParam)
        {
            ICoreAdminService coreAdminService = new CoreAdminService(Area, _serviceProvider);
            var modelType = coreAdminService.GetModelType(model);

            if (modelType == null)
            {
                return(BadRequest($"Model {model} is not found"));
            }

            if (string.IsNullOrEmpty(formType))
            {
                return(BadRequest($"formType is required"));
            }

            if (formType == "MainForm")
            {
                var result = await coreAdminService.GetLookUpForMainForm(modelType, fieldName, filterParam);

                if (result != null)
                {
                    return(Ok(result));
                }
            }

            if (string.IsNullOrEmpty(formName))
            {
                return(BadRequest($"formName is required for ChildForm and CustomForm"));
            }

            if (formType == "ChildForm")
            {
                var result = await coreAdminService.GetLookUpForChildForm(modelType, formName, fieldName, filterParam);

                if (result != null)
                {
                    return(Ok(result));
                }
            }
            else //if (formType == "CustomForm")
            {
                var result = await coreAdminService.GetLookUpForCustomForm(modelType, formName, fieldName, filterParam);

                if (result != null)
                {
                    return(Ok(result));
                }
            }

            return(NotFound());
        }