public async Task <IActionResult> PutCustomer(int id, Customer customer) { if (id != customer.CustomerId) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public bool update(City city) { bool flag = false; if (city.CityId == null) { return(flag = false); } using (_context = new BlueContext()) { using (var _transaction = _context.Database.BeginTransaction(IsolationLevel.Serializable)) { try { _context.Entry <City>(city).State = EntityState.Modified; _context.SaveChanges(); _transaction.Commit(); flag = true; } catch (Exception e) { _transaction.Rollback(); throw new Exception(e.Message); } } } return(flag); }
public async Task <IActionResult> PutBooking(int id, Booking booking) { if (id != booking.BookingId) { return(BadRequest()); } _context.Entry(booking).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public bool update(User user) { bool flag = false; if (user.UserId == null) { return(flag = false); } using (_context = new BlueContext()) { using (var _transaction = _context.Database.BeginTransaction(IsolationLevel.Serializable)) { try { if (_context.Database.Connection.State == ConnectionState.Closed || _context.Database.Connection.State == ConnectionState.Broken) { _context.Database.Connection.Open(); } _context.Entry <User>(user).State = EntityState.Modified; _context.SaveChanges(); _transaction.Commit(); flag = true; } catch (Exception e) { _transaction.Rollback(); throw new Exception(e.Message); } } } return(flag); }
public async Task <IActionResult> PutRoom(int id, Room room) { if (id != room.RoomId) { return(BadRequest()); } _context.Entry(room).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutHotel(int id, Hotel hotel) { if (id != hotel.HotelId) { return(BadRequest()); } _context.Entry(hotel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAddress(int id, Address address) { if (id != address.AddressId) { return(BadRequest()); } _context.Entry(address).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }