Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        public string GetTrig(RequestObject req)
        {
            string      trigs     = "";
            MyUserModel userModel = new MyUserModel();
            MyUser      myUser    = new MyUser();

            myUser = userModel.GetUserByName(req.username);
            if (myUser != null)
            {
                trigs = myUser.Triggers;
            }
            return(trigs);
        }
Ejemplo n.º 3
0
        public string GetComp(RequestObject req)
        {
            string      comps     = "";
            MyUserModel userModel = new MyUserModel();

            MyUser myUser = new MyUser();

            myUser = userModel.GetUserByName(req.username);
            if (myUser != null)
            {
                comps = myUser.Companies;
            }
            return(comps);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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());
        }
Ejemplo n.º 7
0
        public string DeleteComp(RequestObject req)
        {
            string      status    = "";
            MyUserModel userModel = new MyUserModel();

            MyUser myUser = new MyUser();

            myUser = userModel.GetUserByName(req.username);

            string        myCompanies = myUser.Companies;
            List <string> allComps    = new List <string>();

            allComps = myCompanies.Split(',').ToList();
            int index = -1;

            for (int j = 0; j < allComps.Count; j++)
            {
                if (allComps[j] == req.comp)
                {
                    index = j;
                }
            }
            if (index > -1)
            {
                allComps.RemoveAt(index);
            }
            string newCompanies = "";

            if (allComps.Count > 0)
            {
                newCompanies = allComps[0];
            }
            for (int j = 1; j < allComps.Count; j++)
            {
                newCompanies += ",";
                newCompanies += allComps[j];
            }
            UpdateCompanies(myUser, newCompanies);
            status = "Success";
            return(status);
        }
Ejemplo n.º 8
0
        public string AddComp(RequestObject req)
        {
            string status = "";

            status += req.comp;
            MyUserModel userModel = new MyUserModel();

            MyUser myUser = new MyUser();

            myUser = userModel.GetUserByName(req.username);

            CompanyModel compModel = new CompanyModel();

            Company c = CreateCompany(req.comp);

            if (myUser != null)
            {
                Company test         = compModel.GetCompanyByName(req.comp);
                string  currentComps = myUser.Companies;
                if (currentComps == "" || currentComps == null)
                {
                    currentComps += req.comp;
                }
                else if (!currentComps.Contains(req.comp))
                {
                    currentComps += "," + req.comp;
                }
                if (test != null)
                {
                    UpdateCompanies(myUser, currentComps);
                    status = "Success";
                }
                else
                {
                    UpdateCompanies(myUser, currentComps);
                    string wasAdded = compModel.InsertCompany(c);
                    status = "Success";
                }
            }
            return(status);
        }
Ejemplo n.º 9
0
        //Start of real GET Methods
        // GET api/Results/GetResults/(name)
        //[ActionName("GetResults")]
        //[HttpGet]
        public object ResultFind(string id)
        {
            MyUserModel userModel = new MyUserModel();

            MyUser myUser = new MyUser();

            string userRes = "";

            myUser = userModel.GetUserByName(id);
            if (myUser != null)
            {
                userRes = myUser.Results;
            }
            else
            {
                return("User is null: " + id);
            }

            ResultModel resModel = new ResultModel();

            List <Trigger4.Result> myResults = new List <Trigger4.Result>();

            myResults = resModel.GetResultsForUser(userRes);

            ResultObject[] x = new ResultObject[myResults.Count];

            for (int i = 0; i < myResults.Count; i++)
            {
                //Fix this shit.
                //Initialize??
                x[i] = new ResultObject();
                //http://stackoverflow.com/questions/20649606/nullreferenceexception-when-assigning-data-to-variable
                x[i].id       = myResults[i].ID;
                x[i].date     = myResults[i].DateSearched.ToString();
                x[i].company  = myResults[i].Company;
                x[i].trigger  = myResults[i].Triggers;
                x[i].bodyText = myResults[i].BodyText;
            }

            return(x);
        }
Ejemplo n.º 10
0
        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>";
            }
        }
Ejemplo n.º 11
0
        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.";
                }
            }
        }
Ejemplo n.º 12
0
        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;
                }
            }
        }
Ejemplo n.º 13
0
        public string AddTrig(RequestObject req)
        {
            MyUserModel userModel = new MyUserModel();

            MyUser myUser = new MyUser();

            myUser = userModel.GetUserByName(req.username);

            string myTriggers = myUser.Triggers;

            if (myTriggers == "" || myTriggers == null)
            {
                myTriggers = req.trig;
            }
            else
            {
                myTriggers += ",";
                myTriggers += req.trig;
            }
            UpdateTriggers(myUser, myTriggers);
            string status = "Success";

            return(status);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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;
                }
            }
        }
Ejemplo n.º 16
0
        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;
                }
            }
        }