コード例 #1
0
        public ActionResult Create(string username, string password, string name, string MiddleName, string surname, string PersonalID, string PhoneNumber, string email, System.DateTime DateOfAppointment, bool active, bool Administrator)
        {
            using (Context _context = new Context()){
                User newUser = new User();

                newUser.Id                = System.Guid.NewGuid();
                newUser.Username          = username;
                newUser.Password          = Password_Hasher.Hash(password);
                newUser.Name              = name;
                newUser.MiddleName        = MiddleName;
                newUser.SurName           = surname;
                newUser.PersonalID        = PersonalID;
                newUser.PhoneNumber       = PhoneNumber;
                newUser.Email             = email;
                newUser.DateOfAppointment = DateOfAppointment;
                newUser.Active            = active;
                newUser.Administrator     = Administrator;

                _context.Users.Add(newUser);
                _context.SaveChanges();

                dynamic mymodel = new System.Dynamic.ExpandoObject();
                mymodel.LoggedUser = SharedData.logged;
                mymodel.Users      = _context.Users.ToList();
                return(View("~/Views/Platform/Users.cshtml", mymodel));
            }
        }
コード例 #2
0
        /// <summary>
        /// Requests a register of a new user.
        /// </summary>
        private void Register()
        {
            Console.Write("Username: "******"Password: ");
            string password    = Console.ReadLine();
            string hashed_pass = Password_Hasher.Hash(password);

            if (!Password_Hasher.Verify(password, hashed_pass))
            {
                return;
            }

            UserBusiness.Register(username, hashed_pass);
        }
コード例 #3
0
        public static void CreateAdmin()
        {
            using (Context _context = new Context()){
                User FirstAdmin = new User();

                FirstAdmin.Id                = Guid.NewGuid();
                FirstAdmin.Username          = "******";
                FirstAdmin.Password          = Password_Hasher.Hash("adminpass");
                FirstAdmin.Name              = "Hristo";
                FirstAdmin.MiddleName        = "Antonov";
                FirstAdmin.SurName           = "Kanev";
                FirstAdmin.PersonalID        = "4568432687";
                FirstAdmin.PhoneNumber       = "0878987668";
                FirstAdmin.Email             = "*****@*****.**";
                FirstAdmin.DateOfAppointment = DateTime.Now;
                FirstAdmin.Active            = true;
                FirstAdmin.Administrator     = true;

                _context.Users.Add(FirstAdmin);
                _context.SaveChanges();
            }
        }