コード例 #1
0
        public async Task Create_booking_returns_null_from_nonexisting_store()
        {
            // Act
            var result = await _repository.Create(236666663);

            // Assert
            Assert.Null(result);
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] BookingFullModel booking)
        {
            var rec = await _bookingRepository.Create(booking.Quest, booking.Date, booking.TimeSlot, booking.Name, booking.Phone,
                                                      booking.Email,
                                                      booking.PromoCode, booking.Comment);

            var chatId = _apiSettings.Value.TelegramChatId;

#pragma warning disable 4014
            _botClient.SendTextMessageAsync(new ChatId(chatId),
#pragma warning restore 4014
                                            $"*New game! [{rec.BsonId}]*\n" +
                                            $"_Quest_: {booking.Quest}, _Date_: {booking.Date}, _Time_: {TimeslotHelper.ToTime(booking.TimeSlot, booking.Quest)}\n" +
                                            $"_Name_: {booking.Name}, _Email_: {booking.Email}, _Phone_: *{booking.Phone}* \n" +
                                            $"_Promo Code_: {booking.PromoCode}\n" +
                                            $"_Comment_: {booking.Comment}",
                                            ParseMode.Markdown);


            return(Ok());
        }
コード例 #3
0
        /// <summary>
        /// Creates new Booking with specified flight number and new Person.
        /// </summary>
        /// <param name="flightNumber">The flight number.</param>
        /// <param name="person">The person.</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Booking Create(string flightNumber, Person person)
        {
            //check if the Flight Exist

            try
            {
                //cehck fist about flight number if exist of not
                var flight = _flightRepository.SingleOrDefault(a => a.Number == flightNumber);
                if (flight == null)
                {
                    throw new FligtNotExistException(nameof(flight));
                }


                //create new person
                _personRepository.Create(person);
                var passengers = new List <Person>()
                {
                    person
                };

                //create new Booking
                var book = new Booking()
                {
                    DateBooking = DateTime.Now,
                    Number      = flightNumber,
                    Customer    = person,
                    Flight      = flight,
                    Passengers  = passengers
                };
                //add the new object to the repository
                _bookingRepository.Create(book);

                return(book);
            }
            catch
            {
                throw;
            }
        }
 private void CreateBooking(BookingsModel model)
 {
     BookingRepository bookingRepo = new BookingRepository(_sqlConnectionString);
     Booking booking = new Booking();
     booking.Dealer = new Dealer();
     booking.Dealer.Id = _userInfo.Id;
     booking.Dealer.Name = _userInfo.DealerName;
     IList<BookingItem> items = new List<BookingItem>();
     foreach (BookingItemModel modelItem in model.BookingItems)
     {
         BookingItem bookingItem = new BookingItem();
         bookingItem.Item = new Item()
         {
             Id = modelItem.LubeItemId
         };
         bookingItem.Package = new Package()
         {
             Id = modelItem.PackageId
         };
         bookingItem.Quantity = modelItem.Quantity;
         bookingItem.Unit = modelItem.Unit;
         items.Add(bookingItem);
     }
     booking.Items = items;
     booking.InvoiceDate = model.InvoiceDate;
     bookingRepo.Create(booking);
 }
コード例 #5
0
ファイル: Repository.Test.cs プロジェクト: renatoavila/hotel
        public void Full()
        {
            // 1 - cadastro das categorias
            ICategoryRepository categoryRepository = new CategoryRepository();

            Category categorySingle = new Category("Single", 230);

            categoryRepository.Create(categorySingle);

            Category categoryStandard = new Category("Standard", 310);

            categoryRepository.Create(categoryStandard);

            Category categoryLuxo = new Category("Luxo", 470);

            categoryRepository.Create(categoryLuxo);

            Assert.True(categoryRepository.Get().Count == 3);

            // 2 - cadastro do quarto

            IRoomRepository roomRepository = new RoomRepository();

            Room roomSingle01 = new Room("01", categorySingle);

            roomRepository.Create(roomSingle01);

            Room roomSingle02 = new Room("02", categorySingle);

            roomRepository.Create(roomSingle02);

            Room roomStandard03 = new Room("03", categoryStandard);

            roomRepository.Create(roomStandard03);

            Room roomStandard04 = new Room("04", categoryStandard);

            roomRepository.Create(roomStandard04);

            Room roomLuxo05 = new Room("05", categoryLuxo);

            roomRepository.Create(roomLuxo05);

            Room roomLuxo06 = new Room("05", categoryLuxo);

            roomRepository.Create(roomLuxo05);

            Assert.True(roomRepository.Get().Count == 6);

            // 3 - cadstro do hospede
            IHotelGuestRepository hotelGuestRepositoryRepository = new HotelGuestRepository();

            HotelGuest hotelGuest = new HotelGuest("João de Barro", "*****@*****.**", "000.111.222-33", "(19) 99999-9999");

            hotelGuestRepositoryRepository.Create(hotelGuest);

            Assert.True(hotelGuestRepositoryRepository.Get().Count == 1);

            // 4 - cadastro da reserva
            IBookingRepository bookingRepository = new BookingRepository();

            Booking booking = new Booking(hotelGuest, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), roomSingle01);

            bookingRepository.Create(booking);

            Assert.True(bookingRepository.Get().Count == 1);
        }