예제 #1
0
        private bool IsValid(string username, string password, out string AF)
        {
            var  crypto  = new SimpleCrypto.PBKDF2();
            bool IsValid = false;

            //using (var db = new SeniorMVC.Models.Final_Senior_DBEntities1())
            //{
            //    var user = db.Users.FirstOrDefault(u => u.Username == username);
            var       prox      = new NashClient.NsashServicesClient();
            UserModel usermodel = new UserModel();

            usermodel.Username = username;
            AF = "N";
            var user = prox.SignIn(usermodel);

            if (user.AdminFlag == 'Y')
            {
                AF = "Y";
            }
            if (user != null)
            {
                string enc = crypto.Compute(password, user.PasswordSalt);
                if (user.Password.Trim() == enc)
                {
                    IsValid = true;
                }
            }

            return(IsValid);
        }
예제 #2
0
        public ActionResult UserDashboard()
        {
            var           prox     = new NashClient.NsashServicesClient();
            List <string> p1strats = new List <string>();

            p1strats.Add("s1");
            p1strats.Add("st1");
            List <string> p2strats = new List <string>();

            p2strats.Add("s2");
            p2strats.Add("st2");
            int p1order = prox.JoinGame("Split&Steal", "Sherlock", p1strats.ToArray());
            int p2order = prox.JoinGame("Split&Steal", "John", p2strats.ToArray());
            var player1 = new NashClient.PF();
            var player2 = new NashClient.PF();

            player1 = prox.CheckGameStatus("Split&Steal", "Sherlock");
            player2 = prox.CheckGameStatus("Split&Steal", "John");
            List <NashClient.NE_Profile>             maxpayoff  = new List <NashClient.NE_Profile>();
            List <NashClient.NE_Profile>             maxpayoff2 = new List <NashClient.NE_Profile>();
            Dictionary <NashClient.NE_Profile, bool> nepref     = new Dictionary <NashClient.NE_Profile, bool>();

            prox.PreferencesGetter("o3 > o1 > o2 = o4", "a", maxpayoff.ToArray());
            nepref = prox.PreferencesGetter("o2 > o1 > o3 = o4", "Majoodi", maxpayoff2.ToArray());
            //List<NashClient.NE_Profile>
            return(View());
        }
예제 #3
0
        public ActionResult REGISTER()//Models.User user)
        {
            try
            {
                //     if (ModelState.IsValid)
                //   {
                //using (var db = new SeniorMVC.Models.Final_Senior_DBEntities1())
                //{
                var prox   = new NashClient.NsashServicesClient();
                var crypto = new SimpleCrypto.PBKDF2();

                var encrypPass = crypto.Compute(Request["Password"].ToString());
                var newUser    = new UserModel();
                newUser.Username     = Request["Username"].ToString();
                newUser.Password     = encrypPass;
                newUser.PasswordSalt = crypto.Salt;
                //db.Users.Add(newUser);
                //db.SaveChanges();
                string result = prox.Register(newUser);
                //, "SignIn");
                if (result == "done!")
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    RedirectToAction("Index");
                }
                //   }
                // }

                //else
                //{
                //    ModelState.AddModelError("", "Data is not correct");
                //}
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                return(View("Error"));
            }
            return(View());
        }
예제 #4
0
        public ActionResult ViewAllGameFrames()
        {
            var prox      = new NashClient.NsashServicesClient();
            var twopgames = prox.ChooseGame(2);
            List <GameFrame> twopgamesmodel = new List <GameFrame>();

            for (int i = 0; i < twopgames.Count(); i++)
            {
                GameFrame temp = new GameFrame();
                temp.Title         = twopgames[i].Title;
                temp.MinPlayers    = twopgames[i].MinPlayers;
                temp.MaxPlayers    = twopgames[i].MaxPlayers;
                temp.MinStrategies = twopgames[i].MinStrategies;
                temp.MaxStrategies = twopgames[i].MaxStrategies;
                twopgamesmodel.Add(temp);
            }
            ViewData["GameFrames"] = twopgamesmodel;
            return(View(twopgamesmodel.ToList()));
        }
예제 #5
0
 public ActionResult Register()//string username , string password)
 {
     NashClient.NsashServicesClient nash = new NashClient.NsashServicesClient();
     NashClient.UserModel           user = new NashClient.UserModel();
     //user.Username = username;
     //user.Username = "******";
     //user.Password = password;
     user.Username  = Request["Username"].ToString();
     user.Password  = Request["Password"].ToString();
     user.AdminFlag = 'N';
     try
     {
         string response = nash.Register(user);
     }
     catch (Exception ex)
     {
         return(View(ex.ToString()));
     }
     // if (response == "done!")
     return(View());
 }
예제 #6
0
        public ActionResult LogIn()
        {
            NashClient.NsashServicesClient nash = new NashClient.NsashServicesClient();
            var NashObj = new NashClient.NsashServicesClient();
            // UserMVC user = new UserMVC();
            UserModel user = new UserModel();
            UserModel s    = new UserModel();

            s.Username = Request["Username"].ToString();
            s.Password = Request["Password"].ToString();
            user       = nash.SignIn(s);
            if (user != null)// this means that there is a user with those creditentials
            {
                // if(user.AdminFlag=='N')
                return(View());
            }
            else
            {
                return(View());
            }
        }