예제 #1
0
        public async Task <IActionResult> PutTCocinero([FromRoute] int id, [FromBody] TCocinero tCocinero)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tCocinero.IdCocinero)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public void initContext()
        {
            var options = new DbContextOptionsBuilder<DbRestauranteContext>()
             .UseInMemoryDatabase(databaseName: "Test_NxRestaurante").Options;
            // Set up a context (connection to the "DB") for writing
            using (var _context = new DbRestauranteContext(options))
            {
                _context.TipoIdentificacion.AddAsync(new Entities.TipoIdentificacion { descripcion = "CC" });
                _context.TipoIdentificacion.AddAsync(new Entities.TipoIdentificacion { descripcion = "TI" });
                _context.TipoIdentificacion.AddAsync(new Entities.TipoIdentificacion { descripcion = "CE" });
                _context.SaveChangesAsync();

                _context.Usuario.AddAsync(new Entities.Usuario
                {
                    identidad = "1017143560",
                    nombre = "Milker",
                    apellido = "Sanchez",
                    contrasenia = "123456",
                    email = "*****@*****.**",
                    tipo = new Entities.TipoIdentificacion { id = 1, descripcion = "CC" }
                });
                _context.SaveChangesAsync();

                dbCarvajalTestContext = _context;
            }


        }
예제 #3
0
        public async Task <IActionResult> PutTDetalleFactura([FromRoute] long id, [FromBody] TDetalleFactura tDetalleFactura)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tDetalleFactura.IdDetalleFactura)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }