コード例 #1
0
        public async Task <IActionResult> Create(SuPageEditGetWithListModel FromForm)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var UserId = CurrentUser.Id;

            if (ModelState.IsValid)
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@PageStatusId",    FromForm.Page.PageStatusId),
                    new SqlParameter("@PageTypeId",      FromForm.Page.PageTypeId),
                    new SqlParameter("@ShowTitle",       FromForm.Page.ShowTitleName),
                    new SqlParameter("@ShowDescription", FromForm.Page.ShowTitleDescription),
                    new SqlParameter("@UserId",          UserId),
                    new SqlParameter("@LanguageId",      CurrentUser.DefaultLanguageId),
                    new SqlParameter("@Name",            FromForm.Page.Name ?? ""),
                    new SqlParameter("@Description",     FromForm.Page.Description ?? ""),
                    new SqlParameter("@MouseOver",       FromForm.Page.MouseOver ?? ""),
                    new SqlParameter("@MenuName",        FromForm.Page.MenuName ?? ""),
                    new SqlParameter("@Title",           FromForm.Page.TitleName ?? ""),
                    new SqlParameter("@PageDescription", FromForm.Page.TitleDescription ?? ""),
                };

                _context.Database.ExecuteSqlCommand("PageCreatePost @PageStatusId, @PageTypeId, @ShowTitle, @ShowDescription, @UserId, @LanguageId, @Name, @Description, @MouseOver, @MenuName, @Title, @PageDescription", parameters);
            }
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public async Task <IActionResult> Create()
        {
            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);


            //var ParentPage = _Page.GetPage(Id);

            var StatusList = new List <SelectListItem>();

            foreach (var StatusFromDb in _PageStatus.GetAllPageStatus())
            {
                StatusList.Add(new SelectListItem
                {
                    Text  = StatusFromDb.Name,
                    Value = StatusFromDb.Id.ToString()
                });
            }

            //wwwwwwwwwwwwwwwwwwwwwwwwww
            var ToForm = (from o in _PageType.GetAllPageTypes()
                          join l in _PageTypeLanguage.GetAllPageTypeLanguages()
                          on o.Id equals l.PageTypeId
                          where l.LanguageId == CurrentUser.DefaultLanguageId
                          select new SuObjectVM
            {
                Id = o.Id
                ,
                Name = l.Name
            }).ToList();

            var TypeList = new List <SelectListItem>();

            foreach (var TypeFromDb in ToForm)
            {
                TypeList.Add(new SelectListItem
                {
                    Text  = TypeFromDb.Name,
                    Value = TypeFromDb.Id.ToString()
                });
            }
            //wwwwwwwwwwwwwwwwwwwwwwww

            //SuObjectVM Parent = new SuObjectVM()
            //{
            //    NullId = ParentPage == null ? 0 : ParentPage.Id,
            //    LanguageId = DefaultLanguageID

            //};
            var Page         = new SuPageEditGetModel();
            var PageAndLists = new SuPageEditGetWithListModel {
                Page = Page, StatusList = StatusList, TypeList = TypeList
            };

            return(View(PageAndLists));
        }