public IActionResult Update(string ID, [FromBody] DriverReg Drive, DriverReg drive1) { try { // save Drive.TimeStamp = DateTime.Now; _context.DriverReg.Update(Drive); _context.SaveChanges(); return(Ok(drive1)); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public IActionResult AddDriver(DriverReg drive, [FromBody] DriverReg driver) { // map dto to entity try { // save drive.ID = Guid.NewGuid().ToString(); driver.TimeStamp = DateTime.UtcNow; _context.DriverReg.Add(driver); _context.SaveChanges(); return(Ok(driver)); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }