public async Task <OrderDetail> UpdateOrderDetailAsync(OrderDetail orderDetail) { _context.Entry <OrderDetail>(orderDetail).State = EntityState.Modified; await _context.SaveChangesAsync(); return(orderDetail); }
public async Task <Product> UpdateProductAsync(Product product) { _context.Entry <Product>(product).State = EntityState.Modified; var recEffected = await _context.SaveChangesAsync(); if (recEffected == 1) { _logger.LogInformation($"EFProductRepository.UpdateProductAsync, Product with ProductId: {product.ProductId}, updated Successfully"); } return(product); }
public ActionResult Edit([Bind(Include = "IdOrder,IdCustomer,OrderDate")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdCustomer = new SelectList(db.Customers, "IdCustomer", "Nazwa", order.IdCustomer); return(View(order)); }
public async Task UpdateAsync(Product product) { try { _context.Entry <Product>(product).State = EntityState.Modified; await _context.SaveChangesAsync(); LogInfo("ProductRepository.UpdateAsync"); } catch (Exception ex) { LogError($"ProductRepository.UpdateAsync - {ex.Message}"); throw; } }
public async Task UpdateAsync(Product product) { try { _context.Entry(product).State = EntityState.Modified; await _context.SaveChangesAsync(); _logger.LogInformation($"ProductRepository.UpdateAsync - product={product}"); } catch (Exception ex) { _logger.LogError(ex, "Error in ProductRepository.UpdateAsync(product={product})"); throw; } }
public async Task <Order> SaveOrderAsync(Order order) { if (order.OrderId == 0) { _context.Orders.Add(order); } else { _context.Entry <Order>(order).State = EntityState.Modified; } if (await _context.SaveChangesAsync() > 0) { return(order); } return(null); }