public async Task <ActionResult <AddShelfResponse> > Add([FromBody] AddShelfRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var room = await houseStockDbContext.Rooms.FindAsync(request.RoomId); if (room == null) { return(BadRequest($"Room with id {request.RoomId} does not exist")); } var shelf = Shelf.Create(request.ShelfName, room); houseStockDbContext.Shelves.Add(shelf); await houseStockDbContext.SaveChangesAsync(); return(Ok(new AddShelfResponse { Name = shelf.Name, Id = shelf.Id, RoomId = room.Id })); }