Пример #1
0
        public async Task <IActionResult> PutBDriveType([FromRoute] int id, [FromBody] BDriveType bDriveType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PostBDriveType([FromBody] BDriveType bDriveType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.BDriveType.Add(bDriveType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBDriveType", new { id = bDriveType.TypeId }, bDriveType));
        }