示例#1
0
        public ActionResult Create(AuthorsModel AuthorsModel_INPUT)
        {
            try
            {
                MenuModel             mm             = new MenuModel();
                List <SelectListItem> AuthorAreaList = new List <SelectListItem>();
                var _AuthorAreaList = mm.GetMenu(MenuModel.MenuClassEnum.AuthorArea);
                for (int i = 0; i < _AuthorAreaList.Count; i++)
                {
                    AuthorAreaList.Add(new SelectListItem()
                    {
                        Text  = _AuthorAreaList[i].MenuName,
                        Value = _AuthorAreaList[i].MenuID.ToString()
                    });
                }
                ViewBag.AuthorAreaList = AuthorAreaList;
                ViewBag.AuthorAreaList = AuthorAreaList;

                List <SelectListItem> AuthorTagList = new List <SelectListItem>();
                var _AuthorTagList = mm.GetMenu(MenuModel.MenuClassEnum.AuthorTag);
                for (int i = 0; i < _AuthorTagList.Count; i++)
                {
                    AuthorTagList.Add(new SelectListItem()
                    {
                        Text  = _AuthorTagList[i].MenuName,
                        Value = _AuthorTagList[i].MenuID.ToString()
                    });
                }
                ViewBag.AuthorTagList = AuthorTagList;
                // TODO: Add insert logic here
                AuthorsModel_INPUT.Create();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#2
0
        public static void 新增藝術家(匯入資料 _匯入資料)
        {
            if (!_匯入資料.藝術家中文名稱.Contains(";"))
            {
                string        中文名        = 處理文字(_匯入資料.藝術家中文名稱);
                string        外文名        = 處理文字(_匯入資料.藝術家外文名稱);
                List <string> _藝術家標籤     = 分割文字(_匯入資料.藝術家標籤);
                List <string> _藝術家區域     = 分割文字(_匯入資料.藝術家區域);
                List <string> AreaNoList = new List <string>();
                AreaNoList.Add("1");
                List <string> TagNoList = new List <string>();
                TagNoList.Add("1");
                using (var context = new EG_MagicCubeEntities())
                {
                    var _Authors = context.Authors.AsQueryable().Where(c => c.AuthorsCName == 中文名).FirstOrDefault();
                    if (_Authors == null)
                    {
                        var 標籤List = 匯入資料List.Where(c => c.藝術家中文名稱 == _匯入資料.藝術家中文名稱).Select(c => c.藝術家標籤).ToList();
                        if (標籤List != null && 標籤List.Count > 0)
                        {
                            foreach (string str in 標籤List)
                            {
                                _藝術家標籤 = 處理標籤(_藝術家標籤, str, true);
                            }
                        }
                        var 區域List = 匯入資料List.Where(c => c.藝術家中文名稱 == _匯入資料.藝術家中文名稱).Select(c => c.藝術家區域).ToList();
                        if (區域List != null && 區域List.Count > 0)
                        {
                            foreach (string str in 區域List)
                            {
                                _藝術家區域 = 處理標籤(_藝術家區域, str, true);
                            }
                        }


                        if (_藝術家標籤 != null && _藝術家標籤.Count > 0)
                        {
                            var _AuthorsTagArray = context.Menu_AuthorsTag.AsQueryable().Where(c => _藝術家標籤.Contains(c.AuthorsTagName)).Select(c => c.AuthorsTagNo).ToList();
                            if (_AuthorsTagArray != null && _AuthorsTagArray.Count > 0)
                            {
                                TagNoList = _AuthorsTagArray.Select(c => c.ToString()).ToList();
                            }
                        }
                        if (_藝術家區域 != null && _藝術家區域.Count > 0)
                        {
                            var _AuthorsAreaArray = context.Menu_AuthorsArea.AsQueryable().Where(c => _藝術家區域.Contains(c.AuthorsAreaName)).Select(c => c.AuthorsAreaNo).ToList();
                            if (_AuthorsAreaArray != null && _AuthorsAreaArray.Count > 0)
                            {
                                AreaNoList = _AuthorsAreaArray.Select(c => c.ToString()).ToList();
                            }
                        }

                        AuthorsModel _AuthorsModel = new AuthorsModel();
                        _AuthorsModel.AuthorsCName              = 中文名;
                        _AuthorsModel.AuthorsEName              = 外文名;
                        _AuthorsModel.ModifyUser                = "******";
                        _AuthorsModel.CreateUser                = "******";
                        _AuthorsModel.AuthorsTagNo_InputString  = TagNoList;
                        _AuthorsModel.AuthorsAreaNo_InputString = AreaNoList;
                        Console.WriteLine(JsonConvert.SerializeObject(_AuthorsModel));
                        _AuthorsModel.Create();
                    }
                }
            }
        }