public async Task <IActionResult> Create(int Id)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var DefaultLanguageID = CurrentUser.DefaultLanguageId;

            var UICustomizationArray = new UICustomization(_context);

            ViewBag.Terms = await UICustomizationArray.UIArray(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), DefaultLanguageID);

            Menus a = new Menus(_context);


            ViewBag.menuItems = await a.TopMenu(DefaultLanguageID);


            var FieldTypeList    = new List <SelectListItem>();
            var parameter        = new SqlParameter("@LanguageId", CurrentUser.DefaultLanguageId);
            var FieldTypesFromDb = _context.ZDbTypeList.FromSql("ContentTypeSelectAllForLanguage @LanguageId", parameter).ToList();

            foreach (var FieldTypeFromDb in FieldTypesFromDb)
            {
                FieldTypeList.Add(new SelectListItem
                {
                    Text  = FieldTypeFromDb.Name,
                    Value = FieldTypeFromDb.Id.ToString()
                });
            }

            SuProcessTemplateFieldEditGetModel ProcessTemplateFieldEditGet = new SuProcessTemplateFieldEditGetModel
            {
                PId = Id
            };
            SuProcessTemplateFieldEditGetWithListModel ProcessTemplateFieldWithList = new SuProcessTemplateFieldEditGetWithListModel
            {
                ProcessTemplateField = ProcessTemplateFieldEditGet,
                FieldTypeList        = FieldTypeList
            };

            return(View(ProcessTemplateFieldWithList));

            //var ProcessTemplateField = new SuObjectVM
            //{
            //    Id = Id
            //                                ,
            //    LanguageId = DefaultLanguageID
            //};

            ////DataTypes
            //var DataTypeList = new List<SelectListItem>();

            //var DataTypesFromDb = _context.ZDbStatusList.FromSql("DataTypeSelectAll").ToList();


            //foreach (var DataTypeFromDb in DataTypesFromDb)
            //{
            //    DataTypeList.Add(new SelectListItem
            //    {
            //        Text = DataTypeFromDb.Name,
            //        Value = DataTypeFromDb.Id.ToString()
            //    });
            //}

            ////ContentType


            ////MasterList
            //var MasterListList = new List<SelectListItem>();

            //var MasterListsFromDb = _context.ZDbTypeList.FromSql("GetMasterList").ToList();


            //foreach (var MasterListFromDb in MasterListsFromDb)
            //{
            //    MasterListList.Add(new SelectListItem
            //    {
            //        Text = MasterListFromDb.Name,
            //        Value = MasterListFromDb.Id.ToString()
            //    });
            //}

            ////MasterList

            //var FieldsAndDropDowns = new SuProcessTemplateFieldWith2DropDown { Field = ProcessTemplateField, DataTypes = DataTypeList, MasterList = MasterListList };


            //return View(FieldsAndDropDowns);
        }
        public async Task <IActionResult> Edit(int Id)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var DefaultLanguageID = CurrentUser.DefaultLanguageId;

            var UICustomizationArray = new UICustomization(_context);

            ViewBag.Terms = await UICustomizationArray.UIArray(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), DefaultLanguageID);

            Menus a = new Menus(_context);


            ViewBag.menuItems = await a.TopMenu(DefaultLanguageID);


            SqlParameter[] parameters =
            {
                new SqlParameter("@LanguageId", CurrentUser.DefaultLanguageId)
                ,                               new SqlParameter("@OId", Id)
            };

            SuProcessTemplateFieldEditGetModel ProcessTemplateFieldEditGet = _context.ZdbSuProcessTemplateFieldEditGet.FromSql("ProcessTemplateFieldEditGet @LanguageId, @OId", parameters).First();

            var FieldTypeList    = new List <SelectListItem>();
            var parameter        = new SqlParameter("@LanguageId", CurrentUser.DefaultLanguageId);
            var FieldTypesFromDb = _context.ZDbTypeList.FromSql("ContentTypeSelectAllForLanguage @LanguageId", parameter).ToList();

            foreach (var FieldTypeFromDb in FieldTypesFromDb)
            {
                FieldTypeList.Add(new SelectListItem
                {
                    Text  = FieldTypeFromDb.Name,
                    Value = FieldTypeFromDb.Id.ToString()
                });
            }

            SuProcessTemplateFieldEditGetWithListModel ProcessTemplateFieldWithList = new SuProcessTemplateFieldEditGetWithListModel
            {
                ProcessTemplateField = ProcessTemplateFieldEditGet,
                FieldTypeList        = FieldTypeList
            };

            return(View(ProcessTemplateFieldWithList));

            //var ProcessTemplateField = (from c in _processTemplateField.GetAllProcessTemplateFields()
            //                            join l in _processTemplateFieldLanguage.GetAllProcessTemplateFieldLanguages()
            //                            on c.Id equals l.ProcessTemplateFieldId
            //                            where c.Id == Id && l.LanguageId == DefaultLanguageID
            //                            orderby l.Name
            //                            select new SuObjectVM
            //                            {
            //                                Id = c.ProcessTemplateId
            //                                ,
            //                                ObjectId = c.Id
            //                                ,
            //                                LanguageId = l.LanguageId
            //                                ,
            //                                ObjectLanguageId = l.Id
            //                                ,
            //                                Name = l.Name
            //                                ,
            //                                Description = l.Description
            //                                ,
            //                                MouseOver = l.MouseOver
            //                                , NotNullId = c.FieldDataTypeId
            //                                , NotNullId2 = c.FieldMasterListId
            //                            }).First();

            ////DataTypes
            //var DataTypeList = new List<SelectListItem>();

            //var DataTypesFromDb = _context.ZDbStatusList.FromSql("DataTypeSelectAll").ToList();


            //foreach (var DataTypeFromDb in DataTypesFromDb)
            //{
            //    DataTypeList.Add(new SelectListItem
            //    {
            //        Text = DataTypeFromDb.Name,
            //        Value = DataTypeFromDb.Id.ToString()
            //    });
            //}

            ////ContentType


            ////MasterList
            //var MasterListList = new List<SelectListItem>();

            //var MasterListsFromDb = _context.ZDbTypeList.FromSql("GetMasterList").ToList();


            //foreach (var MasterListFromDb in MasterListsFromDb)
            //{
            //    MasterListList.Add(new SelectListItem
            //    {
            //        Text = MasterListFromDb.Name,
            //        Value = MasterListFromDb.Id.ToString()
            //    });
            //}

            ////MasterList

            //var FieldsAndDropDowns = new SuProcessTemplateFieldWith2DropDown { Field = ProcessTemplateField, DataTypes = DataTypeList, MasterList = MasterListList } ;


            //return View(FieldsAndDropDowns);
        }