protected void Page_Load(object sender, EventArgs e) { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser u = new MyUser(); u = userModel.GetUserByName(user.Name); MyUser newUse = new MyUser(); newUse.AccountType = 2; newUse.BillingCycle = u.BillingCycle; newUse.Companies = u.Companies; newUse.Email = u.Email; newUse.FirstName = u.FirstName; newUse.GUI = u.GUI; newUse.ID = u.ID; newUse.LastLogin = u.LastLogin; newUse.LastName = u.LastName; newUse.Newsletter = u.Newsletter; newUse.Results = u.Results; newUse.StartDate = u.StartDate; newUse.Triggers = u.Triggers; newUse.UserName = u.UserName; userModel.UpdateMyUser(u.ID, newUse); Response.Redirect("~/Home.aspx"); }
protected void register_Click(object sender, EventArgs e) { UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager. ConnectionStrings["triggerDBConnectionString"].ConnectionString; UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); //Create new user and store in DB IdentityUser user = new IdentityUser(); user.UserName = txtUsername.Text; //Store new user in MyUser database Trigger4.App_Code.Models.MyUserModel model = new Trigger4.App_Code.Models.MyUserModel(); string g = user.Id; MyUser m = CreateMyUser(g); try { //Create user object and add it to the Database IdentityResult result = manager.Create(user, txtPassword.Text); if (result.Succeeded) { //Store user in MyUser dateabase litStatus.Text = model.InsertMyUser(m); //litStatus.Text = "Got Here." //Store user in database var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; //Set to login user by cookie var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); //Login user and redirect to Main (for now) authenticationManager.SignIn(new AuthenticationProperties(), userIdentity); Response.Redirect("~/signup.html"); } else { litStatus.Text = result.Errors.FirstOrDefault(); } } catch (Exception ex) { litStatus.Text = ex.ToString(); } }
protected void btnUpdate_Click(object sender, EventArgs e) { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); MyUser newUser = EditMyUser(myUser); litStatus.Text = userModel.UpdateMyUser(myUser.ID, newUser); }
private MyUser CreateMyUser(string gu) { MyUser mu = new MyUser(); mu.GUI = gu; mu.Email = txtEmail.Text; mu.AccountType = 0; mu.BillingCycle = 0; mu.LastLogin = DateTime.Now; mu.UserName = txtUsername.Text; mu.StartDate = DateTime.Now; mu.Newsletter = "Yes"; return(mu); }
protected void FillPage() { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); txtFirstName.Text = myUser.FirstName; txtLastName.Text = myUser.LastName; txtEmail.Text = myUser.Email; }
public static string[] DeleteFromList(string idNum) { //START HERE int id = Convert.ToInt32(idNum); //DELETE ID NUM STARTED AT 1 //SHOW ERROR MESSAGE VIA JS IF FAIL Companies c = new Companies(); string user = c.GetMyMotherfuckingName(); MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user); string oldComps = myUser.Companies; string[] comps = oldComps.Split(','); var myList = new List <string>(comps); myList.RemoveAt(id - 1); string[] comps2 = myList.ToArray(); string newComp = ""; for (int j = 0; j < comps2.Length; j++) { if (j == 0) { newComp += comps2[j]; } else { newComp += "," + comps2[j]; } } c.UpdateCompanies(myUser, newComp); List <string> retList = new List <string>(); retList.Add("Was successfull"); return(myList.ToArray()); }
private MyUser EditMyUser(MyUser existing) { MyUser mu = new MyUser(); mu.AccountType = existing.AccountType; mu.BillingCycle = existing.BillingCycle; mu.Companies = existing.Companies; mu.Email = txtEmail.Text; mu.FirstName = txtFirstName.Text; mu.GUI = existing.GUI; mu.ID = existing.ID; mu.LastLogin = existing.LastLogin; mu.LastName = txtLastName.Text; mu.Newsletter = existing.Newsletter; mu.Results = existing.Results; mu.StartDate = existing.StartDate; mu.Triggers = existing.Triggers; mu.UserName = existing.UserName; return(mu); }
protected void FillPage() { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); litUsername.Text = myUser.UserName; int btnNumber = 0; if (myUser != null) { if (myUser.Companies != null) { string companies = myUser.Companies; string compList = ""; string[] comps = companies.Split(','); foreach (string s in comps) { btnNumber++; compList += "<li>" + "<h2 class=\"comp\">" + s + "</h2>"; compList += "<button class=\"btn del\" id=\"" + "button" + btnNumber.ToString() + "\" onclick=\"return false;\">Delete</button>"; compList += "</li>"; } litComp.Text = compList; } } litStatus.Text = myUser.AccountType.ToString(); if ((btnNumber >= 8 && myUser.AccountType == 0) || (btnNumber >= 50)) { Button2.Enabled = false; txtComp.Enabled = false; Button2.Visible = false; litStatus.Text = "<p>Maximum Companies Added</p><a href=\"signup.aspx\">Click Here To Upgrade Account</a>"; } }
protected void btnAdd_Click(object sender, EventArgs e) { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); CompanyModel compModel = new CompanyModel(); Company c = CreateCompany(); if (myUser != null) { Company test = compModel.GetCompanyByName(txtComp.Text); string currentComps = myUser.Companies; if (currentComps == "" || currentComps == null) { currentComps += txtComp.Text; } else if (!currentComps.Contains(txtComp.Text)) { currentComps += "," + txtComp.Text; } if (test != null) { UpdateCompanies(myUser, currentComps); litStatus.Text = txtComp.Text + " was successfully added."; } else { UpdateCompanies(myUser, currentComps); string wasAdded = compModel.InsertCompany(c); litStatus.Text = txtComp.Text + " was successfully added."; } } }
protected void FillPage() { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); litUsername.Text = myUser.UserName; if (myUser != null) { if (myUser.Results != null) { string userRes = myUser.Results; ResultModel resModel = new ResultModel(); List<Trigger4.Result> myResults = new List<Trigger4.Result>(); myResults = resModel.GetResultsForUser(userRes); string htmlMain = ""; string date = ""; foreach (Result r in myResults) { date = r.DateSearched.Value.ToString("MM/dd"); htmlMain += "<h2 class=\"date\">" + date + "</h2>"; htmlMain += "<h2 class=\"new\">New</h2>"; htmlMain += "<h2 class=\"comp\">" + r.Company + "</h2>"; htmlMain += "<h2 class=\"trig\">" + r.Triggers + "</h2>"; htmlMain += r.BodyText; htmlMain += "<hr>"; } litMain.Text = htmlMain; } } }
protected void UpdateCompanies(MyUser u, string comps) { MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser.AccountType = u.AccountType; myUser.BillingCycle = u.BillingCycle; myUser.Email = u.Email; myUser.FirstName = u.FirstName; myUser.GUI = u.GUI; myUser.ID = u.ID; myUser.LastLogin = u.LastLogin; myUser.LastName = u.LastName; myUser.Newsletter = u.Newsletter; myUser.Results = u.Results; myUser.StartDate = u.StartDate; myUser.Triggers = u.Triggers; myUser.UserName = u.UserName; myUser.Companies = comps; userModel.UpdateMyUser(myUser.ID, myUser); }
protected void btnCFO_Click(object sender, EventArgs e) { btnCFO.Enabled = false; btnCFO.Visible = false; var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); string myTriggers = myUser.Triggers; if (myTriggers == "" || myTriggers == null) { myTriggers = "CFO"; } else if (!myTriggers.Contains("CFO")) { myTriggers += ",CFO"; } UpdateTriggers(myUser, myTriggers); }
protected void FillPage() { litNewAlerts.Text = "0 new results."; //ADD LOGIC TO GET NUMBER OF ALERTS bool hasAlerts = false; var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); //litUsername.Text = myUser.UserName; myUser.LastLogin = DateTime.Now; if (myUser != null) { //litNewAlerts.Text = myUser.Triggers + "HELLO"; if ((myUser.FirstName == null) || (myUser.FirstName == "")) { litFName.Text = myUser.UserName; } else { litFName.Text = myUser.FirstName; } if ((myUser.Results == null) || (myUser.Results == "")) { if ((myUser.Companies == null) || (myUser.Companies == "")) { if ((myUser.Triggers == null) || (myUser.Triggers == "")) { litMain.Text = "<h3>Welcome to Trigger Find.</h3><h3>Let's get started by adding some companies to follow.</h3><h3>Select the \"Companies\" tab on the left.</h3>"; } else { litMain.Text = "<h3>Now that you have added some companies, let's add some Triggers to follow.</h3><h3>Select the \"Triggers\" tab.</h3>"; } } else { if (myUser.StartDate.Value.Date == DateTime.Now.Date) { litMain.Text = "<h3>Now that your account is set up, check back daily to see any new alerts from your Triggers.</h3>"; } } } if (myUser.Results != null) { string userRes = myUser.Results; //userRes = myUser.Results; ResultModel resModel = new ResultModel(); List <Trigger4.Result> myResults = new List <Trigger4.Result>(); myResults = resModel.GetResultsForUser(userRes); string userTest = "Count: " + myResults.Count.ToString() + ". String: " + userRes; DateTime last = myUser.LastLogin.Value.AddDays(-1); List <int> toDel = new List <int>(); foreach (Result re in myResults) { if (last.Date < re.DateSearched.Value.Date) { toDel.Add(re.ID); } } foreach (int id in toDel) { Result del = resModel.GetResult(id); myResults.Remove(del); } List <Result> sortedList = myResults.OrderByDescending(o => o.DateSearched).ToList(); if (myResults.Count == 1) { litNewAlerts.Text = myResults.Count.ToString() + " New Alert."; } else if (myResults.Count > 1) { litNewAlerts.Text = myResults.Count.ToString() + " New Alerts."; } if (myResults.Count == 0) { litNewAlerts.Text = "0 New Alerts."; //litNewAlerts.Text = userRes; } string htmlMain = ""; string date = ""; foreach (Result r in sortedList) { date = r.DateSearched.Value.ToString("MM/dd"); htmlMain += "<h2 class=\"date\">" + date + "</h2>"; htmlMain += "<h2 class=\"new\">New</h2>"; htmlMain += "<h2 class=\"comp\">" + r.Company + "</h2>"; htmlMain += "<h2 class=\"trig\">" + r.Triggers + "</h2>"; htmlMain += r.BodyText; htmlMain += "<hr>"; } litMain.Text = htmlMain; } } }
protected void FillPage() { var user = Context.User.Identity; MyUserModel userModel = new MyUserModel(); MyUser myUser = new MyUser(); myUser = userModel.GetUserByName(user.Name); litUsername.Text = myUser.UserName; List <string> trigs = new List <string>(); if (myUser != null) { if (myUser.Triggers != null) { string triggers = myUser.Triggers; string trigList = ""; trigs = triggers.Split(',').ToList(); int btnNumber = 0; foreach (string s in trigs) { btnNumber++; trigList += "<li>" + "<h2 class=\"trig\">" + s + "</h2>"; trigList += "<button class=\"btn del\" id=\"" + "button" + btnNumber.ToString() + "\" onclick=\"return false;\">Delete</button>"; trigList += "</li>"; } litTrig.Text = trigList; } } string[] allTrigs = new string[7] { "Hiring", "Merger", "Sales", "Contracts", "Training", "Location", "CFO" }; if (trigs.Contains("Hiring")) { btnHiring.Visible = false; } if (trigs.Contains("Merger")) { btnMerger.Visible = false; } if (trigs.Contains("Sales")) { btnSales.Visible = false; } if (trigs.Contains("Contracts")) { btnContracts.Visible = false; } if (trigs.Contains("Training")) { btnTraining.Visible = false; } if (trigs.Contains("Location")) { btnLocation.Visible = false; } if (trigs.Contains("CFO")) { btnCFO.Visible = false; } if (myUser != null) { if (myUser.Triggers != null) { string triggers = myUser.Triggers; string trigList = ""; trigs = triggers.Split(',').ToList(); int btnNumber = 0; foreach (string s in trigs) { btnNumber++; trigList += "<li>" + "<h2 class=\"trig\">" + s + "</h2>"; trigList += "<button class=\"btn del\" id=\"" + "button" + btnNumber.ToString() + "\" onclick=\"return false;\">Delete</button>"; trigList += "</li>"; } litTrig.Text = trigList; } } }