예제 #1
0
        public ActionResult Register(string FirstName, string LastName, string Gender, int Age, string State, string Email, string Password)
        {
            User user = new User();

            user.FirstName = FirstName;
            user.LastName  = LastName;
            if (Gender == "Male")
            {
                user.Gender = 0;
            }
            else if (Gender == "Female")
            {
                user.Gender = 1;
            }
            user.Age      = Age;
            user.State    = State;
            user.Email    = Email;
            user.UserName = "******";
            user.Password = Password;

            UserSecurityDAO securityService = new UserSecurityDAO();
            var             result          = securityService.Create(user);

            if (result)
            {
                //return Content("Login Success!");
                return(View("RegisterSuccess", user));
            }
            else
            {
                //return Content("Login Failure...");
                return(View("RegisterFailure", user));
            }
        }
예제 #2
0
        /// <summary>
        /// Entry point for the park reservation cli
        /// </summary>
        /// <param name="args">Command line arguments which are currently ignored</param>
        static void Main(string[] args)
        {
            CLIHelper.EnableDebugInfo = true;

            try
            {
                var builder = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
                IConfigurationRoot configuration = builder.Build();

                string connectionString = configuration.GetConnectionString("npcampground");

                IParkDAO         parkDb         = new ParkDAO(connectionString);
                IUserSecurityDAO userSecurityDb = new UserSecurityDAO(connectionString);
                UserManager      userMgr        = new UserManager(userSecurityDb);

                ParkReservationCLI cli = new ParkReservationCLI(userMgr, parkDb);
                cli.StartMenu();
            }
            catch (Exception e)
            {
                CLIHelper.DisplayDebugInfo(e);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("UserSecurity");

            UserSecurityDAO dao = new UserSecurityDAO(connectionString);
            UserManager     mgr = new UserManager(dao);

            // RegisterUser();

            Console.WriteLine($"Is Authenticate: {mgr.IsAuthenticated}");
            if (!mgr.IsAuthenticated)
            {
                Login(mgr);
            }

            Console.WriteLine($"Is Authenticate: {mgr.IsAuthenticated}");
            if (mgr.IsAuthenticated)
            {
                mgr.LogoutUser();
            }
            Console.WriteLine($"Is Authenticate: {mgr.IsAuthenticated}");
            Console.ReadKey();
        }
예제 #4
0
        public static void TestAuthentication()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            IUserSecurityDAO db      = new UserSecurityDAO(connectionString);
            UserManager      userMgr = new UserManager(db);
            CampgroundDBCLI  cli     = new CampgroundDBCLI(userMgr, connectionString);
            IcampgroundDAO   cgdb    = new CampgroundDAO(connectionString);

            cli.Run();
        }
        static void Main(string[] args)
        {
            // Get the connection string from the appsettings.json file
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            string connectionString = configuration.GetConnectionString("Project");

            IParkDAO           db       = new ParkDAO(connectionString);
            IUserSecurityDAO   security = new UserSecurityDAO(connectionString);
            UserManager        userMgr  = new UserManager(security);
            ParkReservationCLI cli      = new ParkReservationCLI(userMgr, db);

            cli.Run();
        }
예제 #6
0
        public ActionResult Authenticate(string username, string password)
        {
            UserSecurityDAO securityService = new UserSecurityDAO();
            //var result = securityService.FindByUsernameAndPassword(username, password);
            var result = securityService.FindById(1);

            if (result != null)
            {
                //var jsonString = JsonConvert.SerializeObject(
                //result, Formatting.Indented, new JsonConverter[] { new StringEnumConverter() });
                //return Redirect("/Game/Index");
                return(Redirect("/GameBoard"));
            }
            else
            {
                return(View("LoginFailure", username));
            }
        }
예제 #7
0
 public Menu(string connectionString)
 {
     Npsd = new NationalParkSqlDAO(connectionString);
     Dao  = new UserSecurityDAO(connectionString);
     Mgr  = new UserManager(Dao);
 }