public async Task <IActionResult> PutVisitor(long id, Visitor visitor) { if (id != visitor.Id) { return(BadRequest()); } _context.Entry(visitor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VisitorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <int> > NewVisitor(VisitorItem visitorItem) { visitorItem.VisitorIP = HttpContext.Connection.RemoteIpAddress.ToString(); context.VisitorItem.Add(visitorItem); await context.SaveChangesAsync(); var newVisitorItem = context.VisitorItem.OrderByDescending(x => x.Id).FirstOrDefault(); int newId = newVisitorItem.Id; return(Ok(newId)); }