public ActionResult Create(NutritionProfile nutritionProfile) { if (ModelState.IsValid) { //_context.Add(address); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var customer = _context.Customers.Where(c => c.IdentityUserId == userId).First(); customer.nutritionProfile = nutritionProfile; _context.Customers.Update(customer); _context.SaveChanges(); return(RedirectToAction("Index", "Customers")); } return(View(nutritionProfile)); }
public ActionResult Edit(NutritionProfile nutritionProfile) { try { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var customer = _context.Customers.Where(c => c.IdentityUserId == userId).First(); customer.nutritionProfile = nutritionProfile; _context.Customers.Update(customer); _context.SaveChanges(); return(RedirectToAction("Details")); } catch { return(RedirectToAction("Index")); } }
// GET: NutritionProfile/Create public ActionResult Create() { NutritionProfile nutritionProfile = new NutritionProfile(); return(View(nutritionProfile)); }