public async Task <Booking> UpsertAsync(Booking Booking) { var current = await _db.Bookings.FirstOrDefaultAsync(x => x.BookingId == Booking.BookingId); if (null == current) { _db.Bookings.Add(Booking); } else { _db.Entry(current).CurrentValues.SetValues(Booking); } await _db.SaveChangesAsync(); return(Booking); }
public async Task <Room> UpsertAsync(Room Room) { var current = await _db.Rooms .FirstOrDefaultAsync(x => x.RoomId == Room.RoomId); if (null == current) { _db.Rooms.Add(Room); } else { _db.Entry(current).CurrentValues.SetValues(Room); } await _db.SaveChangesAsync(); return(Room); }