Beispiel #1
0
        public async Task <IActionResult> Rankings()
        {
            RankingsModel model = new RankingsModel();

            model.Users = await _context.GetAllUsers();

            if (_userManager.GetUserId(User) != null)
            {
                model.UserId = _userManager.GetUserId(User);
            }
            return(View(model));
        }
        public ActionResult ranking(int Year, String Type, String SubType)
        {
            RankingsModel Rmodel = new RankingsModel();
            String        sql;
            String        sendSubType = SubType;
            String        sendType    = Type;

            if (Type == "Criminal Offense")
            {
                sendType = "CRIMINAL_OFFENSE";
                sql      = "select * from criminal_offense_rank order by incidents desc";
                if (SubType == "Burglary")
                {
                    sendSubType = "BURGLA";
                }
                else if (SubType == "Murder")
                {
                    sendSubType = "MURD";
                }
                else if (SubType == "Vehicle theft")
                {
                    sendSubType = "VEHIC";
                }
                else if (SubType == "Man slaughter")
                {
                    sendSubType = "NEG_M";
                }
                else if (SubType == "Robbery")
                {
                    sendSubType = "ROBBE";
                }
                else if (SubType == "Forcible Sex offence")
                {
                    sendSubType = "FORCIB";
                }
                else if (SubType == "non-forcible sex offence")
                {
                    sendSubType = "NONFOR";
                }
                else if (SubType == "Assault")
                {
                    sendSubType = "AGG_A";
                }
                else
                {
                    sendSubType = "ARSON";
                }
            }
            else if (Type == "Violence Against Women")
            {
                sendType = "VAWA";
                sql      = "select * from vawa_rank order by incidents desc";
                if (SubType == "Stalking")
                {
                    sendSubType = "Stalk";
                }
                else if (SubType == "Dating violence")
                {
                    sendSubType = "Dating";
                }
                else
                {
                    sendSubType = "Domest";
                }
            }
            else if (Type == "Arrests")
            {
                sendType = "ARRESTS";
                sql      = "select * from arrests_rank order by incidents desc";

                if (SubType == "Drug")
                {
                    sendSubType = "DRUG";
                }
                else if (SubType == "Weapon")
                {
                    sendSubType = "Weapon";
                }
                else
                {
                    sendSubType = "Liquor";
                }
            }

            else
            {
                sql      = "select * from discipline_rank order by incidents desc";
                sendType = "DISCIPLINE";
                if (SubType == "Drug")
                {
                    sendSubType = "DRUG";
                }
                else if (SubType == "Weapon")
                {
                    sendSubType = "Weapon";
                }
                else
                {
                    sendSubType = "Liquor";
                }
            }


            Rmodel.answer = new List <RankingsObject>();
            using (connection)
            {
                connection.Open();
                OracleCommand cmd0 = new OracleCommand("GENERATERANKTABLE", connection);
                cmd0.CommandType = System.Data.CommandType.StoredProcedure;

                //cmd0.Parameters.Add(new OracleParameter("TypeFilter", sendType));
                //cmd0.Parameters.Add(new OracleParameter("FocusFilter", sendSubType));
                //cmd0.Parameters.Add(new OracleParameter("yearFilter", Year));

                cmd0.Parameters.Add("TypeFilter", OracleDbType.Varchar2).Value  = sendType;
                cmd0.Parameters.Add("FocusFilter", OracleDbType.Varchar2).Value = sendSubType;
                cmd0.Parameters.Add("yearFilter", OracleDbType.Int32).Value     = Year;
                //OracleDataAdapter da = new OracleDataAdapter(cmd0);
                cmd0.ExecuteNonQuery();

                //sql = "select * from test_table";
                OracleCommand cmd = new OracleCommand(sql, connection);
                cmd.CommandType = System.Data.CommandType.Text;
                OracleDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    RankingsObject robj = new RankingsObject(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4));
                    Rmodel.answer.Add(robj);
                }


                connection.Close();
            }
            return(View("RankingloadGrid", new Tuple <RankingsModel, Discipline>(Rmodel, null)));
        }