Ejemplo n.º 1
0
        public static bool UserIsMemberOfGroupOC(string group, string userName)
        {
            /* Return true immediately if the authorization is not
            locked down to any particular AD group */
            if (String.IsNullOrWhiteSpace(group))
            {
                return true;
            }
            CompXDbContext db = new CompXDbContext();
            UserAccount user = db.UserAccounts.Find(userName.ToLower());
            if (user == null)
                return false;

            if (user.permissionGroup == group)
                return true;

            return false;
        }
Ejemplo n.º 2
0
        public void modifyPrice(double originalPrice, CompXDbContext dbContext)
        {
            //get the parts tolerances from the database
            List<Tolerances> partsTolerances = dbContext.Tolerances.Where(tol => tol.name == Global_Vars.GlobalVars.partsMarkUpTolerance).ToList();
            double partsPercent = Global_Vars.GlobalVars.partsMarkUpPercentFallback;
            double partsMin = Global_Vars.GlobalVars.partsMarkUpMinFallback;
            if (partsTolerances.Count > 0)
            {
                partsPercent = partsTolerances[0].max;
                partsMin = partsTolerances[0].min;
            }

            double markUp = originalPrice * (partsPercent/100);
            if (markUp < partsMin)
                markUp = partsMin;
            this.soldPrice = originalPrice + markUp;
            this.purchasedPrice = originalPrice;
        }
Ejemplo n.º 3
0
        public static bool UserIsMemberOfGroups(string username, string[] groups)
        {
            /* Return true immediately if the authorization is not
            locked down to any particular AD group */
            if (groups == null || groups.Length == 0)
            {
                return true;
            }
            CompXDbContext db = new CompXDbContext();
            UserAccount user = db.UserAccounts.Find(HttpContext.Current.User.Identity.Name.ToLower());
            if (user == null)
                return false;
            foreach (var group in groups)
            {
                if (user.permissionGroup == group)
                    return true;
            }

            return false;
            //OLD FROM ACTIVE DIRECTORY
            // Verify that the user is in the given AD group (if any)x

               /* string connString = ConfigurationManager.ConnectionStrings["ADConnectionString"].ConnectionString;
            int startIndex = connString.IndexOf("//") + 2;
            string domain = connString.Substring(startIndex, connString.IndexOf(".", startIndex) - startIndex);
            var context = new PrincipalContext(ContextType.Domain, domain);
            var userPrincipal = UserPrincipal.FindByIdentity(context,
                                                     IdentityType.SamAccountName,
                                                     username);

                foreach (var group in groups)
                {
                    if (userPrincipal.IsMemberOf(context, IdentityType.Name, group))
                    {
                        return true;
                    }
                }

            return false;*/
        }