Ejemplo n.º 1
0
        public async Task <IActionResult> PutBMaterialType([FromRoute] int id, [FromBody] BMaterialType bMaterialType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PostBMaterialType([FromBody] BMaterialType bMaterialType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.BMaterialType.Add(bMaterialType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBMaterialType", new { id = bMaterialType.TypeId }, bMaterialType));
        }