コード例 #1
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));
        }
コード例 #2
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)));
        }
コード例 #3
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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
            }
        }