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

            _context.BWorkToolKindProperty.Add(bWorkToolKindProperty);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBWorkToolKindProperty", new { id = bWorkToolKindProperty.PptId }, bWorkToolKindProperty));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutBWorkToolKindProperty([FromRoute] int id, [FromBody] BWorkToolKindProperty bWorkToolKindProperty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != bWorkToolKindProperty.PptId)
            {
                return(BadRequest());
            }
            var item = await _context.BWorkToolKindProperty.FindAsync(id);

            if (item == null)
            {
                return(NotFound());
            }
            if (item.PptType != bWorkToolKindProperty.PptType)
            {
                var details = _context.BWorkToolPropertyDetail.Where(e => e.PptId == id);
                _context.BWorkToolPropertyDetail.RemoveRange(details);
            }
            item.PptName     = bWorkToolKindProperty.PptName;
            item.PptType     = bWorkToolKindProperty.PptType;
            item.Description = bWorkToolKindProperty.Description;

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

            return(NoContent());
        }