Exemplo n.º 1
0
        public RoleSerEditResult GetEntityByID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_ID)
        {
            RoleSerEditResult ret = null;

            ret = _client.GetEntityByID(entity_WCFAuthInfoVM, str_ID);
            return(ret);
        }
        public RoleSerEditResult GetEmptyRoleVM(WCFAuthInfoVM entity_WCFAuthInfoVM)
        {
            try
            {
                //Restore Server Session by token
                RetrieveServerSideSession(entity_WCFAuthInfoVM);

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

                RoleSerEditResult returnResult = new RoleSerEditResult();

                bool ret = false;

                ret = CheckTokenOnly(entity_BaseSession, ref strList_Error);

                if (ret)
                {
                    returnResult.Entity_LUserRoleVM = new LUserRoleVM();
                }

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }
        public ActionResult Edit(string ID)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LURoleManage_Edit");

            initFunsList();

            string strError = "";

            RoleSerEditResult wcf_Return = new RoleSerEditResult();

            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                wcf_Return = roleMgtHelper.Value.GetEntityByID(entity_WCFAuthInfoVM, ID);
            });

            if (wcf_Return.StrList_Error.Count > 0 || wcf_Return.Entity_LUserRoleVM == null)
            {
                if (wcf_Return.StrList_Error.Count() > 0)
                {
                    strError = string.Join("<br/>", wcf_Return.StrList_Error.ToArray());
                }

                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc  = strError;
                errorMsgInfo.MsgType  = MessageType.ValidationError;

                LUserRoleVM selectionCriteria = new LUserRoleVM();

                if (TempData.ContainsKey(SelectionCriteriaKey))
                {
                    selectionCriteria = (LUserRoleVM)TempData[SelectionCriteriaKey];
                }

                TempData[SelectionCriteriaKey] = selectionCriteria;

                TempData[ActionMessageKey] = errorMsgInfo;

                return(RedirectToAction("Index"));
            }
            else
            {
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                {
                    List <FunDetailInfo> entityList_FunDetailInfo = orgDetailMgtHelper.Value.GetPrivilegeByUserID(entity_WCFAuthInfoVM, ID, RoleType.Role);

                    wcf_Return.Entity_LUserRoleVM.EntityList_FDInfo = entityList_FunDetailInfo;
                    wcf_Return.Entity_LUserRoleVM.funDListJson      = javaScriptSerializer.Serialize(entityList_FunDetailInfo);
                });
            }

            return(View(wcf_Return.Entity_LUserRoleVM));
        }
        public RoleSerEditResult GetEntityByID(WCFAuthInfoVM entity_WCFAuthInfoVM, string str_RoleID)
        {
            try
            {
                //Retrieve Language And Session
                RetrieveLanguageAndSession(entity_WCFAuthInfoVM);

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

                RoleSerEditResult returnResult = new RoleSerEditResult();

                CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext();

                UserRoleRespository Respo_Role = new UserRoleRespository(dbContext, entity_BaseSession.ID);

                bool ret = false;

                ret = CheckAccPrivilege(entity_BaseSession.ID, entity_WCFAuthInfoVM.RequestFunKey, entity_WCFAuthInfoVM.RequestFunTypeKey, ref strList_Error);

                bool allowEdit = entity_BaseSession.CheckAccessRight(entity_WCFAuthInfoVM.RequestFunKey, "Edit", "", null);
                bool allowDel  = entity_BaseSession.CheckAccessRight(entity_WCFAuthInfoVM.RequestFunKey, "Delete", "", null);

                if (ret)
                {
                    Guid guid_RoleID = default(Guid);
                    if (Guid.TryParse(str_RoleID, out guid_RoleID))
                    {
                        LUserRoleVM db_OrgVM = Respo_Role.GetEntityByID(guid_RoleID, languageKey, ref strList_Error);

                        db_OrgVM.AllowEdit = allowEdit;
                        db_OrgVM.AllowDel  = allowDel;

                        returnResult.Entity_LUserRoleVM = db_OrgVM;
                    }
                    else
                    {
                        ret = false;
                        string str_Message = MultilingualHelper.GetStringFromResource(languageKey, "E012");
                        strList_Error.Add(string.Format(str_Message, "ID"));
                    }
                }

                returnResult.StrList_Error = strList_Error;

                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed);
            }
        }