示例#1
0
        public async Task Should_Save_Reservation()
        {
            var booking = await _bookingDataServices.GetPagedSummaryDoAsync(1, 10);

            var item       = booking.FirstOrDefault();
            var bookingKey = string.Empty;
            var bKey       = await _bookingDataServices.GetBookingItemsCount(item.BookingNumber);

            Assert.NotNull(item);
            using (var dbConnection = SqlExecutor.OpenNewDbConnection())
            {
                var linRes = new LIRESER();
                bookingKey = dbConnection.UniqueId(linRes);
            }
            var reservationNumber = item.BookingNumber;
            var bookingNow        = await _bookingDataServices.GetDoAsync(reservationNumber);

            bookingNow.Value.APELLIDO1 = "GiorgioZoppi";
            var currentList = new List <BookingItemsDto>()
            {
                new BookingItemsDto()
                {
                    Bill       = 1,
                    BookingKey = bKey,
                    Number     = bookingNow.Value.NUMERO_RES,
                    Concept    = 1,
                    Cost       = 1282,
                    Days       = "123"
                }
            };

            bookingNow.Value.Items = bookingNow.Value.Items.Union(currentList);
            var result = await _bookingDataServices.SaveAsync(bookingNow);

            var changed = await _bookingDataServices.GetDoAsync(reservationNumber);

            Assert.AreEqual(result, true);
            Assert.AreEqual(changed.Value.APELLIDO1, bookingNow.Value.APELLIDO1);
            var listOfValues = changed.Value.Items;
            var bookedItem   = listOfValues.Where(x => x.BookingKey == Convert.ToUInt32(bookingKey));
            var bItem        = bookedItem.FirstOrDefault();

            if (bItem != null)
            {
                Assert.AreEqual(bItem.BookingKey, bKey);
                Assert.AreEqual(bItem.Days, "123");
                Assert.AreEqual(bItem.Concept, 1);
                Assert.AreEqual(bItem.Cost, 1282);
                Assert.AreEqual(bItem.Bill, 1);
                Assert.AreEqual(bItem.Number, bookingNow.Value.NUMERO_RES);
            }
        }