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)); }
public IActionResult GuaranteeFormCustomerCreate([FromBody] GuaranteeFormCustomer guaranteeFormCustomer) { try { GuaranteeFormCustomer test = new GuaranteeFormCustomer(); test = guaranteeFormCustomer; if (ModelState.IsValid) { _context.Add(test); _context.SaveChangesAsync(); return(Ok(test)); } else { Console.WriteLine("Không đúng định dạng"); return(BadRequest()); } } catch (ArgumentException err) { Console.WriteLine("Không đúng định dạng", err); return(NotFound()); } }