public async Task <Employee> CreateEmployee(Employee employee) { _context.Add(employee); await _context.SaveChangesAsync(); return(employee); }
public async Task <IActionResult> Create([Bind("Name,Address")][FromBody] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); // We'll return the details of the newly created customer. // The frontend won't know the id we've given the new customer so we want to send this back so it. return(Json(new { success = true, data = customer })); } return(Json(new { success = false, message = "Invalid customer given" })); }