Exemple #1
0
        public void EditeUserInOrgAuth(UserDetailes user, UserContext db)
        {
            UserInOrg uio = null;

            if (user.UserInOrgId > 0)
            {
                uio = db.UserInOrg.FirstOrDefault(x => x.Id == user.UserInOrgId);
            }


            if (uio != null)
            {
                if (!AuthTypes.checkTypeExistence(user.Auth))
                {
                    throw new Exception("");
                }
                //uio.Auth.ToList().ForEach(x => uio.Auth.Remove(x));
                //db.SaveChanges();
                foreach (Auth auth in uio.Auth.ToList())
                {
                    db.Auth.Remove(auth);
                }
                db.SaveChanges();
                user.Auth.ForEach(x => uio.Auth.Add(new Auth {
                    Type = x
                }));
                db.SaveChanges();
            }
        }
Exemple #2
0
 public bool CheckCondition(List <KeyValuePair <ProductInStore, int> > cart, UserDetailes user)
 {
     if (ifCond.CheckCondition(cart, user))
     {
         return(thenCond.CheckCondition(cart, user));
     }
     return(false);
 }
Exemple #3
0
        public bool CheckCondition(List <KeyValuePair <ProductInStore, int> > cart, UserDetailes user)
        {
            switch (this.inlog)
            {
            case LogicalConnections.and:
                return(CheckConditionAnd(cart, user));

            case LogicalConnections.or:
                return(CheckConditionOr(cart, user));
            }
            return(false);//Remove me
        }
Exemple #4
0
        public void DeleteUserInOrg(UserDetailes user, UserContext db)
        {
            department dp = db.department.FirstOrDefault(x => x.AdminId == user.UserInOrgId);

            if (dp != null)
            {
                dp.AdminId         = null;
                db.Entry(dp).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            db.UserInOrg.Remove(db.UserInOrg.Find(user.UserInOrgId)); db.SaveChanges();
        }
 public bool CheckCondition(List <KeyValuePair <ProductInStore, int> > cart, UserDetailes user)
 {
     if (adress != null)
     {
         if (user.Adress != adress)
         {
             return(false);
         }
     }
     if (Isregister == true && user.Isregister != true)
     {
         return(false);
     }
     return(true);
 }
        public void UserConditionPolicy_CheckCondition()
        {
            setup();
            UserDetailes user = new UserDetailes("", false);

            Assert.AreEqual(false, ucp.CheckCondition(null, user), "Registeration and Adress check fail");

            user.Isregister = true;
            Assert.AreEqual(false, ucp.CheckCondition(null, user), "The adress check fail");

            user.Isregister = false;
            user.Adress     = "Tel Aviv";
            Assert.AreEqual(false, ucp.CheckCondition(null, user), "The registeretion check fail");

            user.Isregister = true;
            Assert.AreEqual(true, ucp.CheckCondition(null, user), "Registeration and Adress check fail");
        }
        public void Store_addComplexPurchasePolicy_factoryUserConditionPolicy()
        {
            setup();

            String         details = " ( 3 , Tel Aviv , 1, 0 )";
            PurchasePolicy ucp     = store.addComplexPurchasePolicy(1, details);

            UserDetailes user = new UserDetailes("", false);

            Assert.AreEqual(false, ucp.CheckCondition(null, user), "Registeration and Adress check fail");

            user.Isregister = true;
            Assert.AreEqual(false, ucp.CheckCondition(null, user), "The adress check fail");

            user.Isregister = false;
            user.Adress     = "Tel Aviv";
            Assert.AreEqual(false, ucp.CheckCondition(null, user), "The registeretion check fail");

            user.Isregister = true;
            Assert.AreEqual(true, ucp.CheckCondition(null, user), "Registeration and Adress check fail");
        }
Exemple #8
0
        public void AddUserInOrg(UserDetailes user, UserContext db)
        {
            UserInOrg uio = db.UserInOrg.FirstOrDefault(x => x.UserId == user.UserId && x.OrgId == user.OrgId && x.departmentId == user.departmentId);

            if (uio == null && db.Org.FirstOrDefault(x => x.Id == user.OrgId) != null && db.User.FirstOrDefault(x => x.Id == user.UserId) != null)
            {
                db.UserInOrg.Add(uio = new UserInOrg {
                    departmentId = user.departmentId, OrgId = user.OrgId, UserId = user.UserId
                });

                db.SaveChanges();
                user.Auth.ForEach(x => uio.Auth.Add(new Auth {
                    Type = x
                }));
                db.SaveChanges();
            }
            else
            {
                throw new Exception("");
            }
        }
Exemple #9
0
 public bool CheckConditionOr(List <KeyValuePair <ProductInStore, int> > cart, UserDetailes user)
 {
     foreach (PurchasePolicy policy in children)
     {
         if (policy.CheckCondition(cart, user))
         {
             return(true);
         }
     }
     return(false);
 }