Пример #1
0
        public async Task <IActionResult> Edit(ClientEditViewModel editModel)
        {
            if (ModelState.IsValid)
            {
                Client client = new Client()
                {
                    Id          = editModel.Id,
                    Name        = editModel.Name,
                    Surname     = editModel.Surname,
                    Email       = editModel.Email,
                    PhoneNumber = editModel.PhoneNumber,
                    IsAdult     = editModel.IsAdult
                };

                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        client.Id = editModel.Id;
                    }
                }

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

            return(View(editModel));
        }
Пример #2
0
        public async Task <IActionResult> Edit(ReservationEditViewModel editModel)
        {
            if (ModelState.IsValid)
            {
                Reservation reservation = new Reservation()
                {
                    Id             = editModel.Id,
                    User           = editModel.User,
                    CheckInDate    = editModel.CheckInDate,
                    CheckOutDate   = editModel.CheckOutDate,
                    HasBreakfast   = editModel.HasBreakfast,
                    IsAllInclusive = editModel.IsAllInclusive
                };

                try
                {
                    _context.Update(reservation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReservationExists(reservation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        reservation.Id = editModel.Id;
                    }
                }

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

            return(View(editModel));
        }
Пример #3
0
        public async Task <IActionResult> Edit(RoomsEditViewModel editModel)
        {
            if (ModelState.IsValid)
            {
                Room room = new Room()
                {
                    Id            = editModel.Id,
                    Capacity      = editModel.Capacity,
                    PricePerAdult = editModel.PricePerAdult,
                    PricePerChild = editModel.PricePerChild,
                    IsFree        = editModel.IsFree,
                    Number        = editModel.Number
                };

                try
                {
                    _context.Update(room);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoomExists(room.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        room.Id = editModel.Id;
                    }
                }

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

            return(View(editModel));
        }