Пример #1
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            this.ControllerID = filterContext.RouteData.Values["controller"].ToString();
            this.ActionID     = filterContext.RouteData.Values["action"].ToString();
            var    parameters = filterContext.ActionDescriptor.GetParameters();
            string lang       = "";

            //判斷action是否有帶lang參數
            foreach (var parameter in parameters)
            {
                if (parameter.ParameterName == "lang")
                {
                    lang = filterContext.HttpContext.Request[parameter.ParameterName];
                    break;
                }
            }

            if (string.IsNullOrEmpty(lang))
            {
                PublicMethodRepository.CurrentLanguageEnum = Enums.Language.NotSet;
            }
            else
            {
                PublicMethodRepository.CurrentLanguageEnum = PublicMethodRepository.GetLanguageEnumByCode(lang);
            }

            base.OnAuthorization(filterContext);
        }
        public ActionResult ProductKindAdd(FormCollection form)
        {
            string            langCode = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language          language = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            ListModuleService module   = ListFactoryService.Create(Enums.ListMethodType.PRODUCTKIND);
            int identityId             = module.DoSaveData(form, language);

            return(RedirectToAction("ProductKindEdit", "_SysAdm", new { ID = identityId }));
        }
        public ActionResult WorksDataAdd(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images)
        {
            string            langCode = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language          language = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            ListModuleService module   = ListFactoryService.Create(ListMethodType.WORKS);
            int identityId             = module.DoSaveData(form, language, null, image, images);
            var redirectUrl            = new UrlHelper(Request.RequestContext).Action("WorksDataEdit", "_SysAdm", new { ID = identityId });

            return(Json(new { Url = redirectUrl }));
        }
        public ActionResult ProductKindEdit(FormCollection form)
        {
            string                      langCode   = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language                    language   = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            int?                        ID         = Convert.ToInt32(form["ProductKindID"]);
            ListModuleService           module     = ListFactoryService.Create(Enums.ListMethodType.PRODUCTKIND);
            int                         identityId = module.DoSaveData(form, language, ID);
            ProductKindDetailsDataModel model      = (module.DoGetDetailsByID((int)ID) as ProductKindDetailsDataModel);

            return(View(model));
        }
        public ActionResult NewsEdit(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images)
        {
            string               langCode   = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language             language   = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            int?                 ID         = Convert.ToInt32(form["newsID"]);
            ListModuleService    module     = ListFactoryService.Create(Enums.ListMethodType.NEWS);
            int                  identityId = module.DoSaveData(form, language, ID, image, images);
            NewsDetailsDataModel model      = (module.DoGetDetailsByID((int)identityId) as NewsDetailsDataModel);
            //取圖檔
            ImgModule imgModule = new ImgModule();

            model.ImagesData = imgModule.GetImages(model.ID, "News", "S").FirstOrDefault();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("NewsEdit", "_SysAdm", new { ID = identityId });

            return(Json(new { Url = redirectUrl }));
        }
Пример #6
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            this.ControllerID = filterContext.RouteData.Values["controller"].ToString();
            this.ActionID     = filterContext.RouteData.Values["action"].ToString();
            var    parameters = filterContext.ActionDescriptor.GetParameters();
            string lang       = "";

            //判斷action是否有帶lang參數
            foreach (var parameter in parameters)
            {
                if (parameter.ParameterName == "lang")
                {
                    lang = filterContext.HttpContext.Request[parameter.ParameterName];
                    break;
                }
            }
            //var lang = parameters.Select(s => new
            //{
            //    Name = s.ParameterName,
            //    Value = filterContext.HttpContext.Request[s.ParameterName]
            //})
            //.Where(w => w.Name == "lang").FirstOrDefault();

            if (string.IsNullOrEmpty(lang))
            {
                PublicMethodRepository.CurrentLanguageEnum = Enums.Language.NotSet;
            }
            else
            {
                PublicMethodRepository.CurrentLanguageEnum = PublicMethodRepository.GetLanguageEnumByCode(lang);
            }


            base.OnAuthorization(filterContext);

            //string ip = filterContext.RequestContext.HttpContext.Request.UserHostAddress;
            //IpHistoryModule.WriteIp(ip);
        }
        public ActionResult ProductDataEdit(FormCollection form, List <HttpPostedFileBase> image, List <HttpPostedFileBase> images)
        {
            string            langCode   = form["lang"] ?? PublicMethodRepository.CurrentLanguageCode;
            Language          language   = PublicMethodRepository.GetLanguageEnumByCode(langCode);
            int?              ID         = Convert.ToInt32(form["ProductID"]);
            ProductKindModule typeModule = new ProductKindModule();

            #region 判斷狀態是否已被停用 被停用 不得啟用前台顯示
            if (ID.HasValue)
            {
                int chkTypeID = Convert.ToInt16(form["type"]);
                ProductKindDetailsDataModel tModel = (typeModule.DoGetDetailsByID(chkTypeID) as ProductKindDetailsDataModel);
                bool tpStatus  = tModel.Status == "Y" ? true : false;
                bool setStatus = form["fSt"] == null ? false : true;
                if ((!tpStatus) && (setStatus))
                {
                    var redirectErrorUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = ID, error = true });
                    return(Json(new { Url = redirectErrorUrl }));
                }
            }

            #endregion
            ListModuleService module      = ListFactoryService.Create(ListMethodType.PRODUCT);
            int identityId                = module.DoSaveData(form, language, ID, image, images);
            ProductDetailsDataModel model = (module.DoGetDetailsByID((int)identityId) as ProductDetailsDataModel);
            //取圖檔
            ImgModule imgModule = new ImgModule();
            model.ImagesData      = imgModule.GetImages(model.ID, "Product", "S").FirstOrDefault();
            model.OtherImagesData = imgModule.GetImages(model.ID, "Product", "M");
            //產品分類下拉選單
            SelectList typeList = typeModule.CreateProductKindDropList(model.TypeID, false, model.DisplayForFrontEnd);
            ViewBag.TypeList = typeList;

            var redirectUrl = new UrlHelper(Request.RequestContext).Action("ProductDataEdit", "_SysAdm", new { ID = identityId });
            return(Json(new { Url = redirectUrl }));
        }