Exemplo n.º 1
0
 public ActionResult SignUp()
 {
     string content = Request.QueryString["a"].Replace("25252", "+");
     extreemt.crypt algo = new extreemt.crypt();
     string decryptedId = algo.Decrypt(content);
     string[] user = decryptedId.Split(new char[] { '$', '$', '$' });
     int i = 0;
     while (user[i] == "")
     {
         i++;
     }
     if (user[i] != "2" && user[i] != "3")
         return null;
     ViewData["parentGenNumber"] = user[i];
     i++;
     while (user[i] == "")
     {
         i++;
     }
     if (user[i] != "left" && user[i] != "right")
         return null;
     ViewData["myPos"] = user[i];
     i++;
     while (user[i] == "")
     {
         i++;
     }
     ViewData["parentId"] = user[i];
     ViewData["a"] = content;
     return View();
 }
Exemplo n.º 2
0
        public Dictionary<string, List<string>> validateSignUp()
        {
            this.errors = new Dictionary<string, List<string>>();

            if (!Account.isUserLogged())
            {
                addError("user", "<p>user Not Logged</p>");
                return this.errors;
            }
            string content = this.Form["a"];

            extreemt.crypt algo = new extreemt.crypt();
            string decryptedId = algo.Decrypt(content);
            string[] user = decryptedId.Split(new char[] { '$', '$', '$' });
            int i = 0;
            while (user[i] == "")
            {
                i++;
            }
            if (user[i] != "2" && user[i] != "3")
            {

                addError("user", "<p>error</p>");
                return this.errors;
            }
            i++;
            while (user[i] == "")
            {
                i++;
            }
            if (user[i] != "left" && user[i] != "right")
            {
                addError("user", "<p>error</p>");
                return this.errors;
            }
            i++;
            while (user[i] == "")
            {
                i++;
            }
            string parentIdd = user[i];

            int parentId = int.Parse(parentIdd);

            extreemtEntities db = new extreemtEntities();
            if (db.users.Where(o => o.userId == parentId).Count() <= 0)
            {
                addError("parentId", "<p>parent don't exist<p>");
                return this.errors;
            }

            if (validateAccount.mailExisits(this.Form["mail"]))
            {
                addError("mail", "<p>Mail Exists - please choose another one</p>");
                return this.errors;

            }

            if (validateAccount.usernameExisits(this.Form["username"]))
            {
                addError("username", "<p>username Exists - please choose another one</p>");
                return this.errors;
            }

            //existance
            List<string> requiredFields = new List<string> { "mail", "title", "username", "mobile"
            ,"country","city" , "address" ,"ssn" ,"nationality"
             , "loginPassword" , "confirmLoginPassword" , "binCode"
            ,"confirmBinCode"
            };
            this.required(requiredFields);
            //length
            ////exact
            Dictionary<string, int> exactLength = new Dictionary<string, int>();
            exactLength.Add("ssn", 14);
            exactLength.Add("mobile", 11);
            if (this.Form["homephone"] != "" && this.Form["homephone"] != null)
            {
                exactLength.Add("homephone", 8);
            }
            exact(exactLength);

            ////range
            Dictionary<string, List<int>> rangeLength = new Dictionary<string, List<int>>();
            rangeLength.Add("mail", new List<int> { 5, 30 });
            rangeLength.Add("username", new List<int> { 3, 30 });

            rangeLength.Add("city", new List<int> { 3, 30 });
            rangeLength.Add("address", new List<int> { 3, 100 });
            rangeLength.Add("nationality", new List<int> { 3, 30 });
            rangeLength.Add("loginPassword", new List<int> { 5, 30 });
            rangeLength.Add("binCode", new List<int> { 5, 30 });
            range(rangeLength);

            //password

            if (tools.trimMoreThanOneSpace(this.Form["loginPassword"]) != tools.trimMoreThanOneSpace(this.Form["confirmLoginPassword"]))
                addError("confirmLoginPassword", "<p>Login password and confirm login password aren't exact</p>");

            if (tools.trimMoreThanOneSpace(this.Form["binCode"]) != tools.trimMoreThanOneSpace(this.Form["confirmBinCode"]))
                addError("confirmBinCode", "<p>Bin Code and confirm Bin code aren't exact</p>");

            //inclusion

            //pattern
            if (!validation.IsValidEmail(tools.trimMoreThanOneSpace(this.Form["mail"])))
                addError("mail", "<p>E-mail not valid</p>");
            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["username"])))
                addError("username", "<p>First Name not valid</p>");

            if (!validation.isNumeric(tools.trimMoreThanOneSpace(this.Form["mobile"])))
                addError("mobile", "<p>Mobile not valid</p>");

            if (this.Form["homephone"] != "" && this.Form["homephone"] != null)
            {
                if (!validation.isNumeric(tools.trimMoreThanOneSpace(this.Form["homephone"])))
                    addError("homephone", "<p>Home Phone not valid</p>");
            }

            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["city"])))
                addError("city", "<p>City not valid</p>");
            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["address"])))
                addError("address", "<p>Address not valid</p>");
            if (!validation.isNumeric(tools.trimMoreThanOneSpace(this.Form["ssn"])))
                addError("ssn", "<p>SSN(ID Number) not valid</p>");
            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["nationality"])))
                addError("nationality", "<p>Nationality not valid</p>");

            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["loginPassword"])))
                addError("loginPassword", "<p>Login Password not valid</p>");
            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["confirmLoginPassword"])))
                addError("confirmLoginPassword", "<p>Confirm Login Password not valid</p>");
            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["binCode"])))
                addError("binCode", "<p>Bin Code not valid</p>");
            if (!validation.isAlphaNumeric(tools.trimMoreThanOneSpace(this.Form["confirmBinCode"])))
                addError("confirmBinCode", "<p>Confirm Bin Code not valid</p>");

            return this.errors;
        }
Exemplo n.º 3
0
        public void submitSignUp()
        {
            Account acc = new Account(this);
            Dictionary<string, List<string>> errors = acc.signUp();
            if (errors != null)
            {
                foreach (KeyValuePair<string, List<string>> error in errors)
                {
                    Response.Write(error.Key + ",");
                    foreach (string msg in error.Value)
                    {
                        Response.Write(msg);

                    }
                    Response.Write("#");
                }
            }
            else
            {
                string userId = (string)Session["userId"];
                if (userId != null && userId != "")
                {
                    extreemt.crypt algo = new extreemt.crypt();
                    userId = algo.Encrypt(userId + "$$$1");
                    userId = HttpUtility.UrlEncode(userId.Replace("+", "25252"));
                }
                string url = Url.Action("genology", "Home") + "?a=" + userId;
                //Response.Redirect(url);

                Response.Write("success," + url);
            }
        }
Exemplo n.º 4
0
        private void insertUser()
        {
            string content = this.accountController.Request.Form["a"];

            extreemt.crypt algo = new extreemt.crypt();
            string decryptedId = algo.Decrypt(content);
            string[] userr = decryptedId.Split(new char[] { '$', '$', '$' });
            int i = 0;
            while (userr[i] == "")
            {
                i++;
            }

            string parentGenNumber = userr[i];
            i++;
            while (userr[i] == "")
            {
                i++;
            }

            string myPos = userr[i];
            i++;
            while (userr[i] == "")
            {
                i++;
            }
            string parentIdd = userr[i];

            extreemtEntities db = new extreemtEntities();
            int parId = int.Parse(parentIdd);

            int parGenNumber = int.Parse(parentGenNumber);
            if (db.users.Where(u => u.parentUserId == parId && u.position == myPos && u.parentGenNum == parGenNumber).Count() > 0)
            {
                return;
            }
            string userId = (string)HttpContext.Current.Session["userId"];
            if (userId != null && userId != "")
            {
                int currentUserId = int.Parse(userId);
                user current = db.users.Where(u => u.userId == currentUserId && u.genNumber == 1).First();
                //current.credit -= 250;
                db.Entry(current).State = System.Data.EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                return;
            }

            if (!userHaveEnoughMoneyForRegister(this.getLoggedUser()))
            {
                Dictionary<string, List<string>> errors = new Dictionary<string, List<string>>();
                errors.Add("Parent Doesn't Have Enouph Money", new List<string> { "You Don't Have Enouph Money" });
                return;
            }

            user user = new user();
            user.mail = tools.trimMoreThanOneSpace(this.accountController.Request.Form["mail"]);
            user.title = tools.trimMoreThanOneSpace(this.accountController.Request.Form["title"]);
            user.username = tools.trimMoreThanOneSpace(this.accountController.Request.Form["username"]);
            user.mobile = tools.trimMoreThanOneSpace(this.accountController.Request.Form["mobile"]);
            user.homephone = tools.trimMoreThanOneSpace(this.accountController.Request.Form["homephone"]);
            user.country = tools.trimMoreThanOneSpace(this.accountController.Request.Form["country"]);
            user.city = tools.trimMoreThanOneSpace(this.accountController.Request.Form["city"]);
            user.address = tools.trimMoreThanOneSpace(this.accountController.Request.Form["address"]);
            user.ssn = tools.trimMoreThanOneSpace(this.accountController.Request.Form["ssn"]);
            user.nationality = tools.trimMoreThanOneSpace(this.accountController.Request.Form["nationality"]);
            user.relationship = tools.trimMoreThanOneSpace(this.accountController.Request.Form["relationship"]);
            user.loginPassword = tools.trimMoreThanOneSpace(this.accountController.Request.Form["loginPassword"]);
            user.walletPassword = tools.trimMoreThanOneSpace(this.accountController.Request.Form["binCode"]);
            user.parentUserId = int.Parse(parentIdd);
            user.position = myPos;
            user.parentGenNum = int.Parse(parentGenNumber);
            user.genNumber = 1;
            user.status = "inActive";
            user.leftActiveCount = 0;
            user.rightActiveCount = 0;
            user.rightInactiveCount = 1;
            user.leftInactiveCount = 1;
            user.registererId = int.Parse(HttpContext.Current.Session["userId"].ToString());

            user.userId = int.Parse(tools.generateRandomNumber(8));
            db.users.Add(user);

            db.SaveChanges();
            user leftUser = user;
            leftUser.parentGenNum = 1;
            leftUser.parentUserId = user.userId;
            leftUser.genNumber = 2;
            leftUser.position = "left";
            leftUser.leftInactiveCount = 0;
            leftUser.rightInactiveCount = 0;
            leftUser.status = "inActive";
            db.users.Add(leftUser);

            db.SaveChanges();
            user rightUser = user;
            rightUser.parentGenNum = 1;
            rightUser.parentUserId = user.userId;
            rightUser.genNumber = 3;
            rightUser.position = "right";
            rightUser.leftInactiveCount = 0;
            rightUser.rightInactiveCount = 0;
            rightUser.status = "inActive";
            db.users.Add(rightUser);
            db.SaveChanges();
            user parent = db.users.Where(u => u.userId == user.userId && u.genNumber == 1).First();
            this.UpdateParents(parent);
            this.cutOffCashCredit(this.getLoggedUser(), 250);
            //update parents
        }