Esempio n. 1
0
        public JsonResult GetEntityTableFields(string table)
        {
            var entityBO = BusinessLogic.Core.GetFactory().GetInstance <IEntityBO>();
            var columns  = entityBO.GetColumns(table);

            List <EntityFieldModel> entityFieldList = (List <EntityFieldModel>)Session["EntityFieldList"];

            entityFieldList.RemoveAll(o => !o.UserDefined);

            StringBuilder sb = new StringBuilder();

            foreach (var item in columns)
            {
                EntityFieldModel model = new EntityFieldModel();
                model.UserDefined = false;
                model.Name        = item.Key;
                model.Type        = entityBO.GetColumnType(item.Value);
                var entity = entityFieldList.Where(o => o.Name.Equals(item.Key, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
                if (entity != null)
                {
                    entity.UserDefined = false;
                    entity.Name        = item.Key;
                }
                else
                {
                    entityFieldList.Add(model);
                }

                sb.Append(HtmlHelperExtender.RenderPartialViewToString(this, "Partial/NewEntityField", model));
            }

            Session["EntityFieldList"] = entityFieldList;
            return(Json(sb.ToString(), JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult SetEntityStatus(string statusFieldId, string tableName)
        {
            List <EntityStatusModel> entityStatusList = (List <EntityStatusModel>)Session["EntityStatusList"];

            if (entityStatusList.Count > 0)
            {
                return(Json(string.Empty, JsonRequestBehavior.AllowGet));
            }

            var entityBO   = BusinessLogic.Core.GetFactory().GetInstance <IEntityBO>();
            var valuesList = entityBO.GetColumnValues(statusFieldId, tableName).Take(10);

            entityStatusList.RemoveAll(o => true);

            StringBuilder sb = new StringBuilder();

            foreach (var item in valuesList)
            {
                var entityStatus = new EntityStatusModel()
                {
                    Code = item, Description = item, EditMode = true
                };
                entityStatusList.Add(entityStatus);
                sb.AppendLine(HtmlHelperExtender.RenderPartialViewToString(this, "Partial/NewEntityStatus", entityStatus));
            }
            Session["EntityStatusList"] = entityStatusList;

            return(Json(sb.ToString(), JsonRequestBehavior.AllowGet));
        }