public async Task <IActionResult> PutHotel([FromRoute] int id, [FromBody] Hotel hotel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            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());
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("HotelId,PhoneNumber,Address,HotelName,Star,City,Country")] Hotel hotel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hotel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("ClientId,ClientName,ClientSurname,Password,Username")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(profile(client.Username, client.Password)));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("RoomId,HotelId,Capacity,Aircondition,Minibar,Television")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HotelId"] = new SelectList(_context.Hotel, "HotelId", "Address", room.HotelId);
            return(View(room));
        }
        public async Task <IActionResult> Create([Bind("StaffId,HotelId,StaffName,StaffSurname,Password,Username")] Staff staff)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staff);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HotelId"] = new SelectList(_context.Hotel, "HotelId", "Address", staff.HotelId);
            return(View(staff));
        }
        public async Task <IActionResult> Create([Bind("BookId,ClientId,RoomId,CheckinDate,CheckoutDate")] Booking booking)
        {
            var book = from b in _context.Booking
                       select b;

            if (book.Any(b => b.RoomId.Equals(booking.RoomId) && b.CheckinDate.Equals(booking.CheckinDate)) && booking.CheckoutDate.Equals(booking.CheckoutDate))
            {
                return(StatusCode(406, "The room is invalid at this times."));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    _context.Add(booking);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                ViewData["ClientId"] = new SelectList(_context.Client, "ClientId", "ClientName", booking.ClientId);
                ViewData["RoomId"]   = new SelectList(_context.Room, "RoomId", "RoomId", booking.RoomId);
                return(View(booking));
            }
        }