public async Task <IActionResult> Add([FromBody] InputPhotoShoot input) { var shot = input.ToPhotoShoot(); if (await _context.Orders.FindAsync(shot.OrderId) == null) { return(NotFound()); } await _context.PhotoShoots.AddAsync(shot); await _context.SaveChangesAsync(); var output = new OutputPhotoShoot(shot, true); return(CreatedAtAction("GetById", new { id = shot.ResourceId }, output)); }
public async Task <IActionResult> Update(Guid id, [FromBody] InputPhotoShoot input) { var entry = await _context.PhotoShoots .FirstOrDefaultAsync(row => row.ResourceId == id); if (entry == null) { return(NotFound()); } var updated = input.ToPhotoShoot(); entry.OrderId = updated.OrderId; entry.Address = updated.Address; entry.Start = updated.Start; entry.Duration = updated.Duration; await _context.SaveChangesAsync(); return(Ok(new OutputPhotoShoot(entry, true))); }