Exemplo n.º 1
0
        private void AddTestLogin()
        {
            string password = Util.HashPassword("password");

            //System.Diagnostics.Debug.WriteLine(password);

            Classes.Login login = new Classes.Login()
            {
                Username  = "******",
                Password  = password,
                StaffType = "Counsellor"
            };

            ResolutionsSystem rs   = new ResolutionsSystem();
            SqlCode           code = rs.CreateLogin(login);
        }
Exemplo n.º 2
0
        public IActionResult OnPost()
        {
            System.Diagnostics.Debug.WriteLine("OnPost()");
            System.Diagnostics.Debug.WriteLine($"Username: {Username}");
            System.Diagnostics.Debug.WriteLine($"Password: {Password}");
            System.Diagnostics.Debug.WriteLine($"StaffType: {StaffType}");

            //return Page();

            if (ModelState.IsValid)
            {
                if (Password != PasswordConfirm)
                {
                    Message = "Passwords do not match";
                    return(Page());
                }

                ResolutionsSystem rs = new ResolutionsSystem();

                Login AddLogin = new Login();
                AddLogin.Username  = Username;
                AddLogin.Password  = Password;
                AddLogin.StaffType = StaffType;

                // This one form can do two things, create a login for staff, AND create a counsellor login
                // below the code checks and creates 1 or 2 objects respectively depending if there is a counsellor being added or not
                // edit the SQL stored procedure and resolutionspsych to add new counsellor if needed with the createLogin method path
                SqlCode code = rs.CreateLogin(AddLogin); //create login no matter what

                if (StaffType == "Counsellor")
                {
                    //add counsellor
                    Counsellor newCounsellor = new Counsellor()
                    {
                        Name = CounsellorName
                    };

                    code = rs.CreateCounsellor(newCounsellor);
                }

                /*
                 * if  (CounsellorName.Length==0){
                 *
                 *
                 *  SqlCode code = rs.CreateLogin(AddLogin);
                 * }
                 * else
                 * {
                 *  Counsellor AddCounsellor = new Counsellor();
                 *  AddCounsellor.Name = CounsellorName;
                 * //      SqlCode code = rs.CreateLogin(AddLogin,AddCounsellor);
                 * }
                 */

                Message = "New Staff Added";

                return(Page());
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"StaffType: {StaffType}");
                return(Page());
            }
        }