示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Date,Time,SeatNumber,Details")] ReservationModel reservationModel)
        {
            if (id != reservationModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reservationModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationModelExists(reservationModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservationModel));
        }
示例#2
0
        public async Task <IActionResult> Edit(Reservation reservation)
        {
            if (ModelState.IsValid)
            {
                var type = _res.ReservationTypes.Where(r => r.Id == reservation.ReservationTypeId).FirstOrDefault();
                //reservation.ReservationType.Id = type.ToString();
                var student = await _userManager.GetUserAsync(HttpContext.User);

                //var studentId = student.Id;


                reservation.StudentId         = student.Id;
                reservation.ReservationTypeId = type.Id;

                _res.Update(reservation);
                await _res.SaveChangesAsync();

                _toastNotification.AddSuccessToastMessage("You modified reserve successfully");
                return(RedirectToAction("index"));
            }

            return(View(reservation));
        }
示例#3
0
        public async Task <IActionResult> New([Bind("ReservationId,FirstName,LastName,PassportNumber,CellphoneNumber")] Reservation reservation)

        {
            if (ModelState.IsValid)
            {
                if (reservation.ReservationId == 0)
                {
                    _context.Add(reservation);
                }
                else
                {
                    _context.Update(reservation);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(reservation));
        }