public ActionResult SignUp(Models.UsersModel model) { if (ModelState.IsValid) { var isExist = IsEmailExist(model.EmailID); if (isExist) { ModelState.AddModelError("Email", "Email already exist"); return(View(model)); } Users obj = new Users(); obj.RoleID = 3; obj.FirstName = model.FirstName; obj.LastName = model.LastName; obj.EmailID = model.EmailID; obj.Password = model.Password; obj.IsEmailVerified = model.IsEmailVerified; obj.IsActive = model.IsActive; obj.SecretCode = Guid.NewGuid(); dbobj.Users.Add(obj); dbobj.SaveChanges(); SendVerificationLinkEmail(model.EmailID, model.FirstName, obj.SecretCode.ToString()); TempData["Success"] = "Your account has been successfully created."; } ModelState.Clear(); return(RedirectToAction("SignUp")); }
public ActionResult SignUp(Models.UsersModel model) { if (ModelState.IsValid) { int rc = CreateUser(model.UserName, model.EmailAddress, 0); return(RedirectToAction("Index")); } return(View()); }
public ActionResult GetStats(string ign) { // Create a new instance of the model Models.UsersModel User = new Models.UsersModel(); // Create dynamic API URL string apiUrl = "https://secure.runescape.com/m=hiscore_oldschool_seasonal/index_lite.ws?player=" + ign; // Create Web Request for the API WebRequest request = WebRequest.Create(apiUrl); // Sort any credentials request.Credentials = CredentialCache.DefaultCredentials; // Create WebResponse WebResponse response; // Try search for username try { // Get the response from the server response = request.GetResponse(); } catch { User.Name = "User not found"; return(View("Index", User)); } // Create string response from server string responseFromServer = ""; // Read the data from the API using (Stream dataStream = response.GetResponseStream()) { // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. responseFromServer = reader.ReadToEnd(); } // Close the response. response.Close(); // Split hiscores data string[] lines = responseFromServer.Split(new[] { ",", "\n" }, StringSplitOptions.RemoveEmptyEntries); // Split level and minigames/bosses hiscores apart // if you think this is ugly feel free to change my methodology // string[] stats = new string[72]; // string[] minigames = new string[23]; // string[] bosses = new string[82]; // Array.Copy(lines, 0, stats, 0, 72); // Array.Copy(lines, 72, minigames, 0, 23); // Array.Copy(lines, 94, bosses, 0, 82); // Set the model name User.Name = ign; User.TotalLevel = Convert.ToInt32(lines[1]); User.LeagueScore = Convert.ToInt32(lines[73]); ////set the model boss kc //for(int i = 0; i < bosses.Length; i += 2) //{ // Bosses bossKC = new Bosses(bosses[i], bosses[i + 1]); // User.Bosses.Add(bossKC); //} Player currentPlayer = new Player(User.Name, User.TotalLevel, User.LeagueScore); User.Players.Add(currentPlayer); //===== commented this out for now cos just wanted to see boss kills ===== // Set the model stats //foreach (string s in lines) //{ // User.Stats.Add(s); //} // Return the data to the correct view return(View("Index", User)); }