コード例 #1
0
        public async Task <ActionResult <Disk> > PostDisk(Disk disk)
        {
            this.db.Disks.Add(disk);
            await this.db.SaveChangesAsync();

            return(CreatedAtAction("GetDisk", new { id = disk.Id }, disk));
        }
コード例 #2
0
        public async Task <IActionResult> PutDisk(int id, Disk disk)
        {
            if (id != disk.Id)
            {
                return(BadRequest());
            }

            this.db.Entry(disk).State = EntityState.Modified;

            try
            {
                await this.db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }