public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Email")] User user) { if (id != user.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Content,UserID")] MicroPost microPost) { if (id != microPost.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(microPost); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MicroPostExists(microPost.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(microPost)); }
public IActionResult Edit(int id, Producer producer) { if (id != producer.Id) { return(NotFound()); } if (ModelState.IsValid) { _context.Update(producer); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(producer)); }
public async Task <ActionResult <Toy> > Put(Toy toy) { if (toy == null) { return(BadRequest()); } if (!db.Toys.Any(x => x.Id == toy.Id)) { return(NotFound()); } db.Update(toy); await db.SaveChangesAsync(); return(Ok(toy)); }
public IActionResult Edit(int id, ToyViewModel model) { if (id != model.Toy.ToyID) { return(NotFound()); } if (ModelState.IsValid) { model.Toy.Producer = _producerRepository.GetProducerByID(model.Producer); model.Toy.Category = _categoryRepository.GetCategoryById(model.Category); model.Toy.Condition = (Condition)model.Condition; _context.Update(model.Toy); if (model.Images != null) { var helper = new ImageHelper(_environment); foreach (var image in model.Images) { var imageName = helper.AddImage(image); var gallery = new Gallery() { FileName = imageName, Toy = model.Toy }; _galleryRepository.AddImage(gallery); } } _toyRepository.Save(); return(RedirectToAction("Index")); } return(View(model)); }
public void UpdateToy(Toy toy) { _context.Update(toy); }
public void UpdateProducer(Producer producer) { _context.Update(producer); }
public void Update(Post post) { _context.Update(post); }