public IActionResult Preferences([Bind("FirstName,LastName,UserName,Password,Email")] InstructorM instructor)
        {
            /*var PassID = (int)HttpContext.Session.GetInt32(SessionLoggedID);
             * if (PassID != instructor.ID)
             * {
             *  return NotFound();
             * }*/
            var PassID = HttpContext.Session.GetInt32(SessionLoggedID);

            instructor.ID = (int)PassID;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructor.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                ViewBag.Success = "Preferences Updated";
                return(View("InstructorIndex"));
            }
            ViewBag.Error = "Model State Invalid";
            return(View("InstructorIndex"));
        }
Beispiel #2
0
 public void BuyIceCreamFlavor(Customer customer)
 {
     _context.Customers.Add(customer);
     _context.SaveChanges();
 }