public async Task <IHttpActionResult> PutCustomer(string id, Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.Username) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutRoom(int id, Room room) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != room.RoomId) { return(BadRequest()); } db.Entry(room).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> Edit([Bind(Include = "Username,Name,Password")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <ActionResult> Edit([Bind(Include = "BookingId,CustomerUsername,RoomId,CheckInDate,CheckOutDate")] Booking booking) { if (ModelState.IsValid) { db.Entry(booking).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CustomerUsername = new SelectList(db.Customer, "Username", "Name", booking.CustomerUsername); ViewBag.RoomId = new SelectList(db.Room, "RoomId", "RoomId", booking.RoomId); return(View(booking)); }