예제 #1
0
        public async Task <ActionResult <LaptopDetail> > PostLaptopDetail(LaptopDetail laptopDetail)
        {
            _context.laptopDetails.Add(laptopDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLaptopDetail", new { id = laptopDetail.LaptopDetailId }, laptopDetail));
        }
예제 #2
0
        public async Task <IActionResult> PutLaptopDetail(int id, LaptopDetail laptopDetail)
        {
            if (id != laptopDetail.LaptopDetailId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }