Beispiel #1
0
        public async Task <Amenity> CreateOneAmenity(Amenity amenity)
        {
            _context.Amenitites.Add(amenity);
            await _context.SaveChangesAsync();

            return(amenity);
        }
        public async Task <Hotel> CreateHotel(Hotel hotel)
        {
            _context.Hotels.Add(hotel);
            await _context.SaveChangesAsync();

            return(hotel);
        }
Beispiel #3
0
        public async Task <IActionResult> PutAmenities(int id, Amenities amenities)
        {
            if (id != amenities.ID)
            {
                return(BadRequest());
            }

            _context.Entry(amenities).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AmenitiesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public async Task <bool> AddCustomerRecord(CustomerViewModel model)
        {
            try
            {
                Customer newCustomerRecord = new Customer();

                newCustomerRecord.CityID       = Guid.NewGuid().ToString();
                newCustomerRecord.UserID       = model.UserID;
                newCustomerRecord.FirstName    = model.FirstName;
                newCustomerRecord.LastName     = model.LastName;
                newCustomerRecord.StreetNumber = model.StreetNumber;
                newCustomerRecord.Address      = model.Address;
                newCustomerRecord.CityID       = model.CityID;
                newCustomerRecord.PostalCode   = model.PostalCode;
                newCustomerRecord.PhoneNumber  = model.PhoneNumber;
                newCustomerRecord.EmailAddress = model.EmailAddress;

                await _context.Customers.AddAsync(newCustomerRecord);

                return(await _context.SaveChangesAsync() > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <HotelRoom> CreateHotelRoom(HotelRoom hotelRoom)
        {
            _context.HotelRooms.Add(hotelRoom);
            await _context.SaveChangesAsync();

            return(hotelRoom);
        }
Beispiel #6
0
        public virtual async Task <T> AddAsync(T entity)
        {
            _dbContext.Set <T>().Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
Beispiel #7
0
        public async Task <IActionResult> PutRoom(int id, Room room)
        {
            if (id != room.Id)
            {
                return(BadRequest());
            }

            _context.Entry(room).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoomExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <Amenity> Create(Amenity amenity)
        {
            _context.Entry(amenity).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(amenity);
        }
Beispiel #9
0
        public async Task <Amenity> AddAmenity(Amenity amenity)
        {
            _context.Amenity.Add(amenity);
            await _context.SaveChangesAsync();

            return(amenity);
        }
        public async Task <Hotel> CreateHotel(Hotel hotel)
        {
            _context.Entry(hotel).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(hotel);
        }
        public async Task <ActionResult <Hotel> > PostHotel(Hotel hotel)
        {
            _context.Hotels.Add(hotel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHotel", new { id = hotel.Id }, hotel));
        }
Beispiel #12
0
        public async Task SeedDataAsync(HotelDbContext context)
        {
            await context.PaymentTypes.AddAsync(new PaymentType()
            {
                Name = "TestType"
            });

            await context.Users.AddAsync(new HotelUser
            {
                FirstName   = "FirstName",
                LastName    = "LastName",
                Address     = "Address",
                PhoneNumber = "PhoneNumber",
                Email       = "*****@*****.**",
            });

            await context.SaveChangesAsync();

            var reservation = new Reservation
            {
                UserId    = context.Users.First().Id,
                StartDate = new DateTime(2020, 4, 4),
                EndDate   = new DateTime(2020, 4, 8),
                Adults    = 2,
                Kids      = 1,
            };

            await context.Reservations.AddAsync(reservation);

            await context.SaveChangesAsync();
        }
Beispiel #13
0
        public async Task <Room> AddRoom(Room room)
        {
            _context.Room.Add(room);
            await _context.SaveChangesAsync();

            return(room);
        }
        public async Task <Room> CreateRoom(Room room)
        {
            _context.Entry(room).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(room);
        }
Beispiel #15
0
        public async Task <PaymentDomain> CreateAsync(PaymentUpdateModel model)
        {
            var result = await Context.Payments.AddAsync(Mapper.Map <PaymentEntity>(model));

            await Context.SaveChangesAsync();

            return(Mapper.Map <PaymentDomain>(result.Entity));
        }
        public async Task <HotelRoom> Create(HotelRoom hotelRoom, int hotelId)
        {
            hotelRoom.HotelID = hotelId;
            _context.Entry(hotelRoom).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            await _context.SaveChangesAsync();

            return(hotelRoom);
        }
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            await _context.Set <TEntity>().AddAsync(entity);

            await _context.SaveChangesAsync();

            return(entity);
        }
Beispiel #18
0
        public async Task <IActionResult> Create([Bind("Id,Capacity,Type,PriceForAdult,PriceForKid,Number")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Layout")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
Beispiel #20
0
        public async Task <IActionResult> Create([Bind("ID,HotelName,Address,City,State,Zip")] Hotel hotel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hotel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(hotel));
        }
Beispiel #21
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,PhoneNumber,Email,IsAdult")] Client client)
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
        public async Task <IActionResult> Create([Bind("ID,Name")] Amenity amenity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(amenity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(amenity));
        }
Beispiel #23
0
        public async Task AddAmenityToRoom(int roomId, int amenityId)
        {
            var roomAmenity = new RoomAmenity
            {
                AmenityId = amenityId,
                RoomId    = roomId,
            };

            _context.RoomAmenities.Add(roomAmenity);
            await _context.SaveChangesAsync();
        }
        public async Task <IActionResult> Create([Bind("HotelID,RoomNumber,RoomID,RoomName,RoomRate,PetFriendly")] HotelRoom hotelRoom)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hotelRoom);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HotelID"] = new SelectList(_context.Hotel, "ID", "HotelName", hotelRoom.HotelID);
            return(View(hotelRoom));
        }
Beispiel #25
0
        protected async Task <Room> CreateAndSaveTestRoom()
        {
            var room = new Room {
                Name = "Studio Room", Layout = Room.RoomLayout.Studio
            };

            _db.Rooms.Add(room);
            await _db.SaveChangesAsync();

            Assert.NotEqual(0, room.Id);
            return(room);
        }
Beispiel #26
0
        protected async Task <Hotel> CreateAndSaveTestHotel()
        {
            var hotel = new Hotel {
                Name = "Love Shack", StreetAddress = "6969 Doggy Street", City = "Ballplay", State = State.AL, Country = "USA", Phone = "555-000-6969"
            };

            _db.Hotels.Add(hotel);
            await _db.SaveChangesAsync();

            Assert.NotEqual(0, hotel.Id);
            return(hotel);
        }
Beispiel #27
0
        public async Task <IActionResult> Create([Bind("Firstname,Middlename,Lastname,PersonalID,IsActive,IsAdmin,DateOfEmployment,DateOfDischargement,UserName,Email,PhoneNumber")] User user)
        {
            if (ModelState.IsValid)
            {
                user.Id            = Guid.NewGuid().ToString();
                user.SecurityStamp = Guid.NewGuid().ToString();
                _context.Users.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Beispiel #28
0
        public async Task <IActionResult> Create([Bind("AmenityID,RoomID")] RoomAmenity roomAmenity)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roomAmenity);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AmenityID"] = new SelectList(_context.Amenities, "ID", "Name", roomAmenity.AmenityID);
            ViewData["RoomID"]    = new SelectList(_context.Rooms, "ID", "Name", roomAmenity.RoomID);
            return(View(roomAmenity));
        }
        public async Task <AmenityDTO> CreateAmenity(AmenityDTO amenity)
        {
            // convert the amenityDTO to an actual entity

            Amenities entity = new Amenities()
            {
                Name = amenity.Name
            };

            _context.Entry(entity).State = EntityState.Added;
            await _context.SaveChangesAsync();

            return(amenity);
        }
        public async Task AddRoomAsync(long hotelId, CreateHotelRoom hotelRoom)
        {
            var newHotelRoom = new HotelRoom
            {
                HotelId     = hotelId,
                RoomNumber  = hotelRoom.RoomNumber,
                RoomId      = hotelRoom.RoomId,
                PetFriendly = hotelRoom.PetFriendly,
                Rate        = hotelRoom.Rate
            };

            _context.HotelRooms.Add(newHotelRoom);
            await _context.SaveChangesAsync();
        }