public ActionResult Edit(LUserRoleVM entity_VM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LURoleManage_Edit");

            initFunsList();

            ModelState.Clear();
            TryValidateModel(entity_VM);

            if (!ErrorMsgHelper.CustomValiation(str_MsgBoxTitle, ModelState, ViewBag))
            {
                return(View(entity_VM));
            }

            string strError = "";

            if (!string.IsNullOrWhiteSpace(entity_VM.funDListJson))
            {
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

                entity_VM.EntityList_FDInfo = javaScriptSerializer.Deserialize <List <FunDetailInfo> >(entity_VM.funDListJson);
            }

            WCFReturnResult entity_Return = new WCFReturnResult();

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_Return = roleMgtHelper.Value.Update(entity_WCFAuthInfoVM, entity_VM);
            });

            if (entity_Return != null && entity_Return.StrList_Error.Count() > 0)
            {
                strError = string.Join("<br/>", entity_Return.StrList_Error.ToArray());
            }

            if (entity_Return != null && entity_Return.IsSuccess)
            {
                webCommonHelper.RefreshSeverSideSession(this, this.HttpContext, postOffice.LoginUserMgtSerPath);

                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I000");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(RedirectToAction("Index"));
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
                return(View(entity_VM));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Delete(FormCollection collection)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string           str_MsgBoxTitle  = MultilingualHelper.GetStringFromResource(languageKey, "FManage_Edit");
            string           str_ID           = collection["ID"];
            string           str_ErrorMsg     = "";
            CommonJsonResult commonJsonResult = new CommonJsonResult();

            commonJsonResult.MsgTitle = str_MsgBoxTitle;

            WCFReturnResult ret             = new WCFReturnResult();
            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                ret = funMgtHelper.Value.Delete(entity_WCFAuthInfoVM, str_ID);
            });

            if (ret != null && ret.IsSuccess)
            {
                //Refresh Server Side Session
                webCommonHelper.RefreshSeverSideSession(this, this.HttpContext, postOffice.LoginUserMgtSerPath);

                commonJsonResult.ReturnUrl = Url.Action("Index", "FManage", new { Area = "AccessControl" }, Request.Url.Scheme);
                commonJsonResult.Success   = true;

                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I001");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(Json(commonJsonResult));
            }
            else
            {
                if (ret.StrList_Error.Count > 0)
                {
                    str_ErrorMsg = string.Join("<br/>", ret.StrList_Error.ToArray());

                    commonJsonResult.ReturnUrl = Url.Action("Index", "FManage", new { Area = "AccessControl" }, Request.Url.Scheme);
                    commonJsonResult.Success   = false;

                    MsgInfo errorMsgInfo = new MsgInfo();
                    errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                    errorMsgInfo.MsgDesc       = str_ErrorMsg;
                    errorMsgInfo.MsgType       = MessageType.ValidationError;
                    TempData[ActionMessageKey] = errorMsgInfo;
                    return(Json(commonJsonResult));
                }
                else
                {
                    commonJsonResult.ReturnUrl = Url.Action("Index", "FManage", new { Area = "AccessControl" }, Request.Url.Scheme);
                    commonJsonResult.Success   = false;

                    MsgInfo errorMsgInfo = new MsgInfo();
                    errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                    errorMsgInfo.MsgDesc       = MultilingualHelper.GetStringFromResource(languageKey, "E006");
                    errorMsgInfo.MsgType       = MessageType.ValidationError;
                    TempData[ActionMessageKey] = errorMsgInfo;
                    return(Json(commonJsonResult));
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult Edit(LUserOrganizationVM organizationVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LUOrganizationManage_Edit");

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            List <LUserRoleVM> entityList_RoleVM = new List <LUserRoleVM>();
            List <FunctionVM>  entityList_FunVM  = new List <FunctionVM>();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entityList_FunVM = funMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);

                entityList_RoleVM = roleMgtHelper.Value.GetAll(entity_WCFAuthInfoVM);
            });

            ViewBag.RoleList = webCommonHelper.GetSelectList(entityList_RoleVM, "RoleName", "ID", true);

            entityList_FunVM.ForEach(current => current.FunctionKey = current.FunctionPath + " - " + MultilingualHelper.GetStringFromResource(current.FunctionKey));

            ViewBag.FunIDs = webCommonHelper.GetSelectList(entityList_FunVM, "FunctionKey", "ID", true);

            ModelState.Clear();
            TryValidateModel(organizationVM);

            if (!ErrorMsgHelper.CustomValiation(str_MsgBoxTitle, ModelState, ViewBag))
            {
                return(View(organizationVM));
            }

            string strError = "";

            WCFReturnResult entity_Return = new WCFReturnResult();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_Return = orgMgtHelper.Value.Update(entity_WCFAuthInfoVM, organizationVM);
            });

            if (entity_Return != null && entity_Return.IsSuccess)
            {
                webCommonHelper.RefreshSeverSideSession(this, this.HttpContext, postOffice.LoginUserMgtSerPath);
            }

            if (entity_Return != null && entity_Return.StrList_Error.Count() > 0)
            {
                strError = string.Join("<br/>", entity_Return.StrList_Error.ToArray());
            }

            if (entity_Return != null && entity_Return.IsSuccess)
            {
                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I000");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(RedirectToAction("Index"));
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
                return(View(organizationVM));
            }
        }
        public ActionResult Edit(LoginUserVM loginUserVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LoginUserManage_Edit");

            List <string> strList_Error = new List <string>();

            //Retrieve Drop Down List Item
            RetrieveDropDownListInfo();

            //Error Message
            string strError = "";

            LoginUserVM entityInst_Existing = null;

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            //Define object to receive service result
            LUSerEditResult entity_LUSerEditResult = new LUSerEditResult();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                entity_LUSerEditResult = loginUserMgtHelper.Value.GetEntityByID(entity_WCFAuthInfoVM, loginUserVM.ID.ToString());
            });

            if (entity_LUSerEditResult.StrList_Error.Count > 0)
            {
                foreach (var item in entity_LUSerEditResult.StrList_Error)
                {
                    strList_Error.Add(item);
                }
            }
            else
            {
                entityInst_Existing = entity_LUSerEditResult.Entity_LoginUserVM;

                if (loginUserVM.isChangePwd)
                {
                    loginUserVM.LoginPwd = loginUserVM.NewPwd;
                }
                else
                {
                    loginUserVM.LoginPwd = loginUserVM.NewPwd = loginUserVM.ConfirmNewPwd = entityInst_Existing.LoginPwd;
                }

                ModelState.Clear();
                TryValidateModel(loginUserVM);

                if (!ErrorMsgHelper.CustomValiation(str_MsgBoxTitle, ModelState, ViewBag))
                {
                    return(View(loginUserVM));
                }

                if (loginUserVM.UserType.HasValue && loginUserVM.UserType.Value == 1 && !string.IsNullOrWhiteSpace(loginUserVM.funDListJson))
                {
                    JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

                    loginUserVM.EntityList_FDInfo = javaScriptSerializer.Deserialize <List <FunDetailInfo> >(loginUserVM.funDListJson);
                }

                WCFReturnResult entity_Return = new WCFReturnResult();

                //webCommonHelper.CallWCFHelper<ILoginUserMgtSer>(this, this.HttpContext, postOffice.LoginUserMgtSerPath, (entity_ILoginUserMgtSer, entity_WCFAuthInfoVM) =>
                //{
                //    entity_Return = entity_ILoginUserMgtSer.Update(entity_WCFAuthInfoVM, loginUserVM);
                //});

                webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                {
                    entity_Return = loginUserMgtHelper.Value.Update(entity_WCFAuthInfoVM, loginUserVM);
                });

                // Refresh Server Side Session
                if (entity_Return != null && entity_Return.IsSuccess)
                {
                    webCommonHelper.RefreshSeverSideSession(this, this.HttpContext, postOffice.LoginUserMgtSerPath);
                }

                if (entity_Return.StrList_Error.Count > 0)
                {
                    foreach (var item in entity_Return.StrList_Error)
                    {
                        strList_Error.Add(item);
                    }
                }
            }

            if (strList_Error.Count > 0)
            {
                strError = string.Join("<br/>", strList_Error.ToArray());
            }

            if (strList_Error.Count == 0)
            {
                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I000");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(RedirectToAction("Index"));
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;
                ViewBag.ActionMessage = errorMsgInfo;
                return(View(loginUserVM));
            }
        }