Пример #1
0
        public IActionResult Local_event_show()
        {
            string        connection_string = configuration.GetConnectionString("DefaultConnectionString");
            SqlConnection connection        = new SqlConnection(connection_string);

            connection.Open();

            string     query1 = $"select * from LOCAL_EVENT where le_state=1";
            SqlCommand com1   = new SqlCommand(query1, connection);

            var model = new List <Local_Event>();

            using (SqlConnection conn = new SqlConnection(connection_string))
            {
                conn.Open();
                SqlDataReader rdr = com1.ExecuteReader();
                while (rdr.Read())
                {
                    var e = new Local_Event();
                    e.le_id           = (int)rdr["le_id"];
                    e.le_title        = (string)rdr["le_title"];
                    e.le_org_by       = (string)rdr["le_org_by"];
                    e.le_location     = (string)rdr["le_location"];
                    e.le_opening_date = (string)rdr["le_opening_date"];
                    e.le_closing_date = (string)rdr["le_closing_date"];
                    e.le_state        = (int)rdr["le_state"];
                    e.le_pic          = (string)rdr["le_pic"];
                    e.le_details      = (string)rdr["le_details"];

                    model.Add(e);
                }
            }

            return(View(model));
        }
Пример #2
0
        public IActionResult Event_Local_Details(int id)
        {
            var fr = JsonConvert.DeserializeObject <Fundraiser>(HttpContext.Session.GetString("FundraiserSession"));

            ViewBag.d_name = fr.f_name;
            ViewBag.d_id   = fr.f_id;
            //Event e = new Event();
            ViewBag.event_id = id;
            string        connection_string = configuration.GetConnectionString("DefaultConnectionString");
            SqlConnection connection        = new SqlConnection(connection_string);

            connection.Open();
            string        query = $"Select * from LOCAL_EVENT where le_id = {id}";
            SqlCommand    com   = new SqlCommand(query, connection);
            SqlDataReader dr    = com.ExecuteReader();

            while (dr.Read())
            {
                Local_Event e = new Local_Event();
                e.le_title        = (string)dr["le_title"];
                e.le_location     = (string)dr["le_location"];
                e.le_opening_date = (string)dr["le_opening_date"];
                e.le_closing_date = (string)dr["le_closing_date"];
                ViewBag.c_date    = (string)dr["le_closing_date"];

                var daterenew = DateTime.ParseExact(ViewBag.c_date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                ViewBag.r_days = ((daterenew - DateTime.Today).Days) + " day(s) remaining";

                e.le_state        = (int)dr["le_state"];
                e.le_pic          = (string)dr["le_pic"];
                ViewBag.event_pic = (string)dr["le_pic"];
                e.le_details      = (string)dr["le_details"];
                e.le_org_by       = (string)dr["le_org_by"];
                var f_id = (int)dr["f_id"];
                connection.Close();

                string        connection_string2 = configuration.GetConnectionString("DefaultConnectionString");
                SqlConnection connection2        = new SqlConnection(connection_string2);
                connection2.Open();
                string        query2 = $"Select * from USERS where f_id = {f_id}";
                SqlCommand    com2   = new SqlCommand(query2, connection2);
                SqlDataReader dr2    = com2.ExecuteReader();

                while (dr2.Read())
                {
                    ViewBag.org       = (string)dr2["f_name"];
                    ViewBag.org_about = (string)dr2["f_about"];
                    ViewBag.org_phone = (string)dr2["f_phone"];
                }
                connection2.Close();
                return(View(e));
            }
            return(View());
        }
Пример #3
0
        public IActionResult Local_event_show()
        {
            var fr = JsonConvert.DeserializeObject <Fundraiser>(HttpContext.Session.GetString("FundraiserSession"));

            ViewBag.d_name = fr.f_name;
            ViewBag.d_id   = fr.f_id;

            string        connection_string = configuration.GetConnectionString("DefaultConnectionString");
            SqlConnection connection        = new SqlConnection(connection_string);

            connection.Open();

            string     query1 = $"select * from LOCAL_EVENT where le_state=1";
            SqlCommand com1   = new SqlCommand(query1, connection);

            var model = new List <Local_Event>();

            using (SqlConnection conn = new SqlConnection(connection_string))
            {
                conn.Open();
                SqlDataReader rdr = com1.ExecuteReader();
                while (rdr.Read())
                {
                    var e = new Local_Event();
                    e.le_id           = (int)rdr["le_id"];
                    e.le_title        = (string)rdr["le_title"];
                    e.le_org_by       = (string)rdr["le_org_by"];
                    e.le_location     = (string)rdr["le_location"];
                    e.le_opening_date = (string)rdr["le_opening_date"];
                    e.le_closing_date = (string)rdr["le_closing_date"];

                    e.le_state   = (int)rdr["le_state"];
                    e.le_pic     = (string)rdr["le_pic"];
                    e.le_details = (string)rdr["le_details"];

                    model.Add(e);
                }
            }

            return(View(model));
        }