public async Task <IActionResult> Edit(int id, [Bind("Id,SheepingAddress,clientName,phoneNumber,status")] OrderModel orderModel) { if (id != orderModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orderModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderModelExists(orderModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(orderModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Address,ContactPersonName,Email,Name,PhoneNmber")] Supplier supplier) { if (id != supplier.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(supplier); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(supplier.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(supplier)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Color,Depth,Description,Height,Name,Price,Width,amountInStock,tags")] ItemModel itemModel, string imageToDele, [Bind("Image")] ICollection <IFormFile> Image, int supplier) { if (id != itemModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (imageToDele != null && imageToDele != "") { foreach (string imageId in imageToDele.Split(',')) { if (imageId != "") { var img = _context.images.FirstOrDefault(i => i.FileId == int.Parse(imageId)); itemModel.Image.Remove(img); _context.images.Remove(img); } } } saveImages(itemModel, Image); itemModel.supplier = _context.Supplier.FirstOrDefault(m => m.Id == supplier); _context.Update(itemModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemModelExists(itemModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(itemModel)); }