Ejemplo n.º 1
0
        public IEnumerable <BrandBoardGroup> GroupBrandData(IEnumerable <BrandBoardItem> items)
        {
            // group items by rule from customised group utility
            // groupItemNumber is optional parameter. It is futureproof consideration for different groupping rule
            // "others" tag is replaced with "z" to make it alway display at last.
            var groups = items
                         .GroupBy(l => GroupUtility.GetGroupName(l.BrandName, groupItemNumber: 2))
                         .OrderBy(l => l.Key.Replace("Others", "z"));


            var result = new List <BrandBoardGroup>();

            foreach (var group in groups)
            {
                // loop group and sort items in each group with custimised rule
                // the order in given example does not meet any unified rule from my humble option
                // here is a temp rule to match the example
                // rule1: case is not sensitive
                // rule2: if words start with b/e/l [space] is sorted like "s"
                // rule3: "ABC" is after "ABCD"
                var resultItem = new BrandBoardGroup()
                {
                    GroupName = group.Key,
                    Items     = group.ToList()
                                .OrderBy(l => ("BEL".Contains(l.BrandName[0]) ? l.BrandName.Replace(" ", "s") : (l.BrandName + "{")), StringComparer.OrdinalIgnoreCase)
                };
                result.Add(resultItem);
            }
            return(result);
        }
Ejemplo n.º 2
0
        private void populateGeneral()
        {
            //litFunctionSeqId.Text = m_Profile.Id.ToString();
            divFunctionSeqId.InnerHtml = m_Profile.Id.ToString();
            txtName.Value        = m_Profile.Name;
            txtDescription.Value = m_Profile.Description;
            txtNotes.Text        = m_Profile.Notes;
            txtKeyWords.Text     = m_Profile.MetaKeywords;

            divAction.InnerHtml = m_Profile.Action;
            divAction.Visible   = true;
            txtAction.Text      = m_Profile.Action;
            //txtAction.Visible = false;

            txtSource.Text = m_Profile.Source;

            chkEnableViewState.Checked     = m_Profile.EnableViewState;
            chkEnableNotifications.Checked = m_Profile.EnableNotifications;
            chkRedirectOnTimeout.Checked   = m_Profile.RedirectOnTimeout;
            chkNoUI.Checked  = m_Profile.NoUI;
            chkIsNav.Checked = m_Profile.IsNavigable;

            RolesControl.AllRoles            = RoleUtility.GetRolesArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
            RolesControl.SelectedAddRoles    = m_Profile.AssignedAddRoles.ToArray();
            RolesControl.SelectedDeleteRoles = m_Profile.AssignedDeleteRoles.ToArray();
            RolesControl.SelectedEditRoles   = m_Profile.AssignedEditRoles.ToArray();
            RolesControl.SelectedViewRoles   = m_Profile.AssignedViewRoles.ToArray();

            GroupsControl.AllGroups            = GroupUtility.GetGroupsArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
            GroupsControl.SelectedAddGroups    = m_Profile.AddGroups.ToArray();
            GroupsControl.SelectedDeleteGroups = m_Profile.DeleteGroups.ToArray();
            GroupsControl.SelectedEditGroups   = m_Profile.EditGroups.ToArray();
            GroupsControl.SelectedViewGroups   = m_Profile.ViewGroups.ToArray();
        }
Ejemplo n.º 3
0
        public IHttpActionResult SaveMembers(UIAccounts groupAccounts)
        {
            string        mRetVal       = "false";
            Logger        mLog          = Logger.Instance();
            MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile());

            if (!mSecurityInfo.MayEdit)
            {
                Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            if (HttpContext.Current.Items["EditId"] == null || HttpContext.Current.Items["EditId"].ToString().ToLowerInvariant() != groupAccounts.SeqId.ToString().ToLowerInvariant())
            {
                Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            MAccountProfile     accountProfile      = AccountUtility.CurrentProfile();
            MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(accountProfile.Account);
            MGroupRoles         mProfile            = new MGroupRoles();

            mProfile.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id;
            mProfile.GroupSeqId       = groupAccounts.SeqId;
            mProfile.Roles            = String.Join(",", groupAccounts.Accounts);
            mProfile.AddedUpdatedBy   = accountProfile.Id;
            GroupUtility.UpdateGroupRoles(mProfile);
            return(Ok(mRetVal));
        }
Ejemplo n.º 4
0
        public void GetGroupName_BoundaryGroupItemNumber3_ReturnRightName()
        {
            // Arrange
            string itemName = "Zoo";
            // Act
            var result = GroupUtility.GetGroupName(itemName, 2);

            // Assert
            Assert.Equal("Y-Z", result);
        }
Ejemplo n.º 5
0
        public void GetGroupName_CustomizedGroupItemNumber3_ReturnRightName()
        {
            // Arrange
            string itemName = "A2";
            // Act
            var result = GroupUtility.GetGroupName(itemName, 3);

            // Assert
            Assert.Equal("A-C", result);
        }
Ejemplo n.º 6
0
        public void GetGroupName_DefaultGroupItemNumber_ReturnRightName()
        {
            // Arrange
            string itemName = "A2";
            // Act
            var result = GroupUtility.GetGroupName(itemName);

            // Assert
            Assert.Equal("A-B", result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        /// <param name="searchCriteria">The search criteria.</param>
        private void bindData(MSearchCriteria searchCriteria)
        {
            DataTable mDataTable = GroupUtility.Search(searchCriteria);

            if (mDataTable != null && mDataTable.Rows.Count > 0)
            {
                DataView mDataView = mDataTable.DefaultView;
                recordsReturned.Value    = mDataTable.Rows[0][0].ToString();
                searchResults.DataSource = mDataTable;
                searchResults.DataBind();
            }
            else
            {
                noResults.Visible = true;
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String mGroupSeqId = GWWebHelper.GetQueryValue(Request, "GroupSeqID");

            if (!String.IsNullOrEmpty(mGroupSeqId))
            {
                int mGroupID = int.Parse(mGroupSeqId);
                if (mGroupID != -1)
                {
                    m_Profile = GroupUtility.GetProfile(mGroupID);
                }
                else
                {
                    m_Profile = new MGroupProfile();
                }
                HttpContext.Current.Session.Add("EditId", m_Profile.Id);
                populatePage();
            }
        }
Ejemplo n.º 9
0
        public IHttpActionResult Save(MUIGroupProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!");
            }
            string        mRetVal        = "false";
            MGroupProfile mProfileToSave = new MGroupProfile();
            MSecurityInfo mSecurityInfo  = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile());
            Logger        mLog           = Logger.Instance();

            if (HttpContext.Current.Items["EditId"] != null)
            {
                if (profile.Id == -1)
                {
                    if (!mSecurityInfo.MayAdd)
                    {
                        Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                    mProfileToSave.AddedBy   = AccountUtility.CurrentProfile().Id;
                    mProfileToSave.AddedDate = DateTime.Now;
                }
                else
                {
                    if (!mSecurityInfo.MayAdd)
                    {
                        Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                    //mProfileToSave = RoleUtility.GetProfile(profile.Id);

                    mProfileToSave.UpdatedBy   = AccountUtility.CurrentProfile().Id;
                    mProfileToSave.UpdatedDate = DateTime.Now;
                }
            }
            mProfileToSave = populateProfile(profile);
            GroupUtility.Save(mProfileToSave);
            return(Ok(mRetVal));
        }
Ejemplo n.º 10
0
        public IHttpActionResult Delete([FromUri] int groupSeqId)
        {
            string        mRetVal       = "false";
            MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile());

            if (!mSecurityInfo.MayDelete)
            {
                Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to delete");
                Logger    mLog   = Logger.Instance();
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            else
            {
                if (HttpContext.Current.Items["EditId"] != null)
                {
                    int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString());
                    if (mEditId == groupSeqId)
                    {
                        MGroupProfile mProfile = GroupUtility.GetProfile(groupSeqId);
                        GroupUtility.Delete(mProfile);
                    }
                    else
                    {
                        Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                        Logger    mLog   = Logger.Instance();
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                }
                else
                {
                    Exception mError = new Exception("The identifier unknown and nothing has been saved!!!!");
                    Logger    mLog   = Logger.Instance();
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }

            return(Ok(mRetVal));
        }
Ejemplo n.º 11
0
        private void populateRolesAndGroups(MNameValuePair profile)
        {
            int      mSecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString());
            DataView mDVRoles          = RoleUtility.GetAllRolesBySecurityEntity(mSecurityEntityId).DefaultView;
            DataView mDVGroups         = GroupUtility.GetAllGroupsBySecurityEntity(mSecurityEntityId).DefaultView;

            try
            {
                ctlGroups.SelectedItems = NameValuePairUtility.GetSelectedGroups(m_NVPToUpdate.Id);
                ctlRoles.SelectedItems  = NameValuePairUtility.GetSelectedRoles(m_NVPToUpdate.Id);
            }
            catch (Exception ex)
            {
                Logger mLog = Logger.Instance();
                mLog.Debug(ex);
            }
            ctlGroups.DataSource = mDVGroups;
            ctlGroups.DataField  = "Name";
            ctlGroups.DataBind();
            ctlRoles.DataSource = mDVRoles;
            ctlRoles.DataField  = "Name";
            ctlRoles.DataBind();
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MAccountProfile updatingAccount = null;
            MGroupProfile   mGroupProfile   = GroupUtility.GetProfile(int.Parse(HttpContext.Current.Request["GroupSeqId"]));

            txtEditID.Text = mGroupProfile.Id.ToString();
            litGroup.Text  = mGroupProfile.Name;
            HttpContext.Current.Session.Add("EditId", mGroupProfile.Id);
            updatingAccount = AccountUtility.CurrentProfile();

            DataView myDataView = RoleUtility.GetAllRolesBySecurityEntity(int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString())).DefaultView;

            if (!updatingAccount.IsSystemAdmin)
            {
                String rowFilter = "IS_SYSTEM <> 1 AND IS_SYSTEM_ONLY <> 1";
                myDataView.RowFilter = rowFilter;
            }
            try
            {
                MGroupProfile myGroupProfile = new MGroupProfile();
                myGroupProfile = GroupUtility.GetProfile(int.Parse(txtEditID.Text.ToString()));
                litGroup.Text  = myGroupProfile.Name;
                MGroupRoles mProfile = new MGroupRoles();
                mProfile.SecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString());
                mProfile.GroupSeqId       = int.Parse(txtEditID.Text.ToString());
                ctlMembers.SelectedItems  = GroupUtility.GetSelectedRoles(mProfile);
            }
            catch (Exception ex)
            {
                Logger log = Logger.Instance();
                log.Debug(ex);
            }
            ctlMembers.DataSource = myDataView;
            ctlMembers.DataField  = "Name";
            ctlMembers.DataBind();
        }
Ejemplo n.º 13
0
 private void populateGroups()
 {
     ctlGroups.DataSource    = GroupUtility.GetGroupsArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
     ctlGroups.SelectedItems = m_Profile.Groups.ToArray();
     ctlGroups.DataBind();
 }