Exemplo n.º 1
0
        public IActionResult PasswordGenerator()
        {
            var model = new PasswordGenerateDTO();

            model.Length      = 8;
            model.PasswordCnt = 1;
            model.Number      = true;
            model.Lower       = true;
            model.Passwords   = new List <string>();
            return(View(model));
        }
Exemplo n.º 2
0
        public IActionResult PasswordGenerator(PasswordGenerateDTO model)
        {
            model.Passwords = new List <string>();

            if (model.Number == false & model.Lower == false && model.Upper == false)
            {
                ModelState.AddModelError("Condition", "กรุณาระบุเงือนไข");
            }

            if (ModelState.IsValid)
            {
                for (var i = 0; i < model.PasswordCnt; i++)
                {
                    var password = RandomPassword(model.Length, model.Number, model.Lower, model.Upper);
                    model.Passwords.Add(password);
                }
            }
            return(View(model));
        }