Пример #1
0
        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);
        }
Пример #2
0
        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);
        }