示例#1
0
        public async Task <IActionResult> PutContainerLoan([FromRoute] int id, [FromBody] ContainerLoan containerLoan)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != containerLoan.Id)
            {
                return(BadRequest());
            }

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

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

            return(Ok(_context.ContainerLoans.Find(id)));
        }
示例#2
0
        public async Task <IActionResult> PostContainerLoan([FromBody] ContainerLoan containerLoan)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ContainerLoans.Add(containerLoan);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetContainerLoan", new { id = containerLoan.Id }, containerLoan));
        }