Example #1
0
        public async Task <IActionResult> PutMaterial_Prestamo([FromRoute] int id, [FromBody] Material_Prestamo material_Prestamo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PostMaterial_Prestamo([FromBody] Material_Prestamo material_Prestamo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Material_Prestamos.Add(material_Prestamo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMaterial_Prestamo", new { id = material_Prestamo.id }, material_Prestamo));
        }