public async Task <IActionResult> PromotionEdit(int id, [FromBody] Promotion promotion) { if (id != promotion.Id) { Console.WriteLine("Không đúng định dạng"); return(BadRequest()); } if (ModelState.IsValid) { try { _context.Update(promotion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PromotionExists(promotion.Id)) { Console.WriteLine("Id không tồn tại"); return(NotFound()); } else { throw; } } } return(Ok(promotion)); }
public async Task <IActionResult> BillDeliveryInfoItemEdit(int id, [FromBody] BillDeliveryInfoItem billDeliveryInfoItem) { if (id != billDeliveryInfoItem.Id) { Console.WriteLine("Không đúng định dạng"); return(BadRequest()); } if (ModelState.IsValid) { try { _context.Update(billDeliveryInfoItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BillDeliveryInfoItemExists(billDeliveryInfoItem.Id)) { Console.WriteLine("Id không tồn tại"); return(NotFound()); } else { throw; } } } return(Ok(billDeliveryInfoItem)); }
public async Task <IActionResult> GuaranteeFormCustomerEdit(int id, [FromBody] GuaranteeFormCustomer guaranteeFormCustomer) { if (id != guaranteeFormCustomer.Id) { Console.WriteLine("Không đúng định dạng"); return(BadRequest()); } if (ModelState.IsValid) { try { _context.Update(guaranteeFormCustomer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GuaranteeFormCustomerExists(guaranteeFormCustomer.Id)) { Console.WriteLine("Id không tồn tại"); return(NotFound()); } else { throw; } } } return(Ok(guaranteeFormCustomer)); }