コード例 #1
0
        public IActionResult SubmitJunk(string name, string details, string phone)
        {
            Junk junk = new Junk
            {
                Name    = name,
                Details = details,
                Phone   = phone
            };
            DbManager db    = new DbManager(_connectionString);
            int       newId = db.AddJunk(junk);

            if (HttpContext.Session.Get <List <int> >("ListOfIds") == null)
            {
                List <int> idList = new List <int>();
                HttpContext.Session.Set("ListOfIds", idList);
            }
            List <int> idListToAddTo = HttpContext.Session.Get <List <int> >("ListOfIds");

            idListToAddTo.Add(newId);
            HttpContext.Session.Set("ListOfIds", idListToAddTo);
            return(Redirect($"/home/index"));
        }