Ejemplo n.º 1
0
        public async Task <IActionResult> PostVisitorLogTable([FromBody] VisitorLogTable visitorLogTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.VisitorLogTable.Add(visitorLogTable);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (VisitorLogTableExists(visitorLogTable.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetVisitorLogTable", new { id = visitorLogTable.Id }, visitorLogTable));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutVisitorLogTable([FromRoute] int id, [FromBody] VisitorLogTable visitorLogTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != visitorLogTable.Id)
            {
                return(BadRequest());
            }

            _context.Entry(visitorLogTable).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VisitorLogTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }