public async Task <IActionResult> Edit(int id, [Bind("ReservationId,Date,NumberOfChildReservations,NumberOfAdultReservations,roomNumber")] BreakfastReservation breakfastReservation) { if (id != breakfastReservation.ReservationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(breakfastReservation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BreakfastReservationExists(breakfastReservation.ReservationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["roomNumber"] = new SelectList(_context.Rooms, "RoomNumber", "RoomNumber", breakfastReservation.roomNumber); return(View(breakfastReservation)); }
public async Task <IActionResult> Create([Bind("ReservationId,Date,NumberOfChildReservations,NumberOfAdultReservations,roomNumber")] BreakfastReservation breakfastReservation) { if (ModelState.IsValid) { _context.Add(breakfastReservation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["roomNumber"] = new SelectList(_context.Rooms, "RoomNumber", "RoomNumber", breakfastReservation.roomNumber); return(View(breakfastReservation)); }
// POST: api/BreakfastReservations public HttpResponseMessage Post(BreakfastReservation breakfastReservation) { try { var dateWithStudentResult = _breakfastReservationService.GetByDateWithStudent(breakfastReservation.ReservationDate, breakfastReservation.StudentId); if (dateWithStudentResult != null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Kullanıcıya ait Aynı tarihli Rezervasyon bulunuyor.")); } var result = _breakfastReservationService.Add(breakfastReservation); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Hata Oluştu")); } }
public BreakfastReservation Update(BreakfastReservation breakfastReservation) { return(_breakfastReservationDal.Update(breakfastReservation)); }
public BreakfastReservation Add(BreakfastReservation breakfastReservation) { return(_breakfastReservationDal.Add(breakfastReservation)); }