public async Task <IActionResult> Create([Bind("RecipeId,RecipeName,PrepTime,DifficultyLevel,SpiceLevel,Price,IsVeg,Image1,Image2,Image3,CookLimit,ShortDescription,LongDescription,NutritionValue,BoxContent,ChefName,CuisineId")] Recipe recipe) { if (ModelState.IsValid) { _context.Add(recipe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CuisineId"] = new SelectList(_context.Cuisine, "CuisineId", "CuisineName", recipe.CuisineId); return(View(recipe)); }
public async Task <IActionResult> PutUser([FromRoute] int id, [FromBody] User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.UserId) { return(BadRequest()); } //_context.Entry(user.Payment).State = EntityState.Modified; //var paymentToUpdate = _context.Payment.SingleOrDefault(p => p.PaymentId == user.PaymentId); //if (paymentToUpdate != null) // _context.Payment.Update(paymentToUpdate); _context.User.Update(user); //_context.Payment.Update(user.Payment); // _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }