Пример #1
0
 public ActionResult Edit([Bind(Include = "ExpenseInId,Description,Amount,CreatedBy")] ExpenseIn expenseIn)
 {
     if (ModelState.IsValid)
     {
         db.Entry(expenseIn).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(expenseIn));
 }
Пример #2
0
        public IActionResult EditPreferences(string milk, string eggs, string fish, string shellfish, string treenuts, string peanuts, string soy, string wheat, string diet, string privacy)
        {
            AspNetUsers thisUser = _context.AspNetUsers.Where(u => u.UserName == User.Identity.Name).First();

            if (milk == "milk")
            {
                thisUser.Milk = true;
            }
            else
            {
                thisUser.Milk = false;
            }
            if (eggs == "eggs")
            {
                thisUser.Eggs = true;
            }
            else
            {
                thisUser.Eggs = false;
            }
            if (fish == "fish")
            {
                thisUser.Fish = true;
            }
            else
            {
                thisUser.Fish = false;
            }
            if (shellfish == "shellfish")
            {
                thisUser.Shellfish = true;
            }
            else
            {
                thisUser.Shellfish = false;
            }
            if (treenuts == "treenuts")
            {
                thisUser.Treenuts = true;
            }
            else
            {
                thisUser.Treenuts = false;
            }
            if (peanuts == "peanuts")
            {
                thisUser.Peanuts = true;
            }
            else
            {
                thisUser.Peanuts = false;
            }
            if (soy == "soy")
            {
                thisUser.Soy = true;
            }
            else
            {
                thisUser.Soy = false;
            }
            if (wheat == "wheat")
            {
                thisUser.Wheat = true;
            }
            else
            {
                thisUser.Wheat = false;
            }

            if (diet == "none")
            {
                thisUser.Diet = null;
            }
            else
            {
                thisUser.Diet = diet;
            }
            if (privacy == "private")
            {
                thisUser.Private = true;
            }
            else if (privacy == "public")
            {
                thisUser.Private = false;
            }
            _context.Entry(thisUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(RedirectToAction("Userpage"));
        }