예제 #1
0
        public ActionResult BookingCreate([Bind()] BookingContract bookingContract)
        {
            if (ModelState.IsValid)
            {
                var bookingService = new BookingServiceClient();

                bookingContract.Booking.BookingId =
                    bookingService.UpdateBooking(
                        bookingContract.Booking.BookingId,
                        bookingContract.Booking.BookingSourceRcd,
                        bookingContract.BookingIdentifier.BookingIdentifierValue,
                        bookingContract.BookingContactMethod.ContactMethodWay,
                        bookingContract.Booking.ReceivedFrom,
                        bookingContract.Booking.Comment,
                        bookingContract.Booking.FinancialCurrencyId,
                        bookingContract.Booking.FinancialCostcentreId,
                        Logging.UserId(User.Identity, ViewBag)
                        );

                return(RedirectToAction("BookingContacts",
                                        new { bookingId = bookingContract.Booking.BookingId }
                                        ));
            }

            return(View(MVCHelper.Resolve(Request, "", "Booking", "BookingCreate"),
                        bookingContract
                        ));
        }
예제 #2
0
        /// <inheritdoc />
        public async Task <Guid> AddBooking(BookingContract bookingContract)
        {
            // Temporary return
            return(GetDummyGuid());

            // Todo: make repo call
        }
예제 #3
0
파일: Booking.cs 프로젝트: jacov/nor-port
        public void RefreshAddress()
        {
            // fetch booking data
            var bookingService = new BookingServiceClient();

            _bookingContract =
                bookingService.GetBooking(
                    _bookingContract.Booking.BookingId,
                    _userId
                    );
            try {
                addressTypeRefCombo.Text    = _bookingContract.BookingAddress.AddressTypeRcd != null ? _bookingContract.BookingAddress.AddressTypeRcd : String.Empty;
                textBoxAddressOne.Text      = _bookingContract.BookingAddress.AddressOne;
                textBoxAddressTwo.Text      = _bookingContract.BookingAddress.AddressTwo;
                textBoxAddressThree.Text    = _bookingContract.BookingAddress.AddressThree;
                textBoxState.Text           = _bookingContract.BookingAddress.State;
                textBoxDistrict.Text        = _bookingContract.BookingAddress.District;
                textBoxProvince.Text        = _bookingContract.BookingAddress.Province;
                textBoxZipCode.Text         = _bookingContract.BookingAddress.ZipCode;
                textBoxPoBox.Text           = _bookingContract.BookingAddress.PoBox;
                textBoxComment.Text         = _bookingContract.BookingAddress.Comment;
                userPicker.SelectedValue    = _bookingContract.BookingAddress.UserId;
                dateTimePickerDateTime.Text = _bookingContract.BookingAddress.DateTime.ToString();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            } finally {
                bookingService.Close();
            }
        }
예제 #4
0
        public ActionResult BookingCreate()
        {
            // default values
            var             bookingService  = new BookingServiceClient();
            BookingContract bookingContract = bookingService.GetBookingEmpty(Logging.UserId(User.Identity, ViewBag));

            // todo, session id can't be trusted
            bookingContract.Booking.BookingId        = new Guid(Session["SessionID"].ToString());
            bookingContract.Booking.BookingSourceRcd = BookingSourceRef.InternalSystem;

            bookingContract.BookingIdentifier = new CrudeBookingIdentifierContract();
            bookingContract.BookingIdentifier.BookingIdentifierTypeRcd = BookingIdentifierTypeRef.RecordLocator;
            bookingContract.BookingIdentifier.BookingIdentifierValue   = new BookingServiceClient().LocatorCreate();

            // get user id
            ViewBag.UserId = Logging.UserId(User.Identity, ViewBag);

            // refs
            List <CrudeBookingSourceRefContract> refs =
                new BusinessLogicLayer.CrudeBookingSourceRefServiceClient().FetchAll();

            ViewBag.BookingSourceRcd =
                new SelectList(
                    refs,
                    "BookingSourceRcd",
                    "BookingSourceName",
                    bookingContract.Booking.BookingSourceRcd
                    );

            return(View(MVCHelper.Resolve(Request, "", "Booking", "BookingCreate"),
                        bookingContract
                        ));
        }
예제 #5
0
 public int Book(BookingContract booking)
 {
     return(this.IsFree(booking)
         ? this.repository.Create(new Booking {
         HotelId = booking.HotelId, Start = booking.Start, End = booking.Start.AddDays(booking.Duration)
     })
         : 0);
 }
예제 #6
0
        public async Task <IActionResult> AddBooking([FromBody] BookingContract bookingContract)
        {
            if (bookingContract == null)
            {
                return(BadRequest());
            }

            var bookingConfirmation = await _bookingService.AddBooking(bookingContract);

            return(Ok(bookingConfirmation));
        }
예제 #7
0
파일: Booking.cs 프로젝트: jacov/nor-port
        public void ShowAsAdd(
            Guid userId
            )
        {
            _userId = userId;

            var bookingService = new BookingServiceClient();

            _bookingContract = bookingService.GetBookingEmpty(userId);
            _bookingContract.BookingIdentifier = new CrudeBookingIdentifierContract();
            _bookingContract.BookingIdentifier.BookingIdentifierValue = new BookingServiceClient().LocatorCreate();
            _bookingContract.Booking.BookingSourceRcd = BookingSourceRef.InternalSystem;
            _bookingContract.BookingPassengers        = new List <BookingPassengersContract>();

            RefreshBooking();

            Show();
        }
예제 #8
0
파일: Booking.cs 프로젝트: jacov/nor-port
        public void ShowAsEdit(
            Guid bookingId,
            Guid userId
            )
        {
            _userId = userId;

            // get booking with new booking contract
            var bookingService = new BookingServiceClient();

            _bookingContract =
                bookingService.GetBooking(
                    bookingId,
                    _userId
                    );

            RefreshBooking();

            Show();
        }
예제 #9
0
        public bool IsFree(BookingContract booking)
        {
            if (booking.Duration < 1)
            {
                throw new ArgumentException("Duration is less than 1");
            }

            var bookingEnd = booking.Start.AddDays(booking.Duration);

            var bookings = this.repository.GetAll <Booking>(b =>
                                                            b.HotelId == booking.HotelId &&
                                                            (
                                                                (b.Start >= booking.Start && b.Start <= bookingEnd) ||
                                                                (b.End >= booking.Start && b.End <= bookingEnd) ||
                                                                (b.Start <= booking.Start && b.End >= bookingEnd)
                                                            )
                                                            );

            return(bookings.Count() == 0);
        }
예제 #10
0
        public void Create_ValidData_Should_CreateBooking()
        {
            // Arrange
            this.repository.Create(new Booking {
                HotelId = 1, Start = DateTime.UtcNow.AddDays(-2), End = DateTime.UtcNow.AddDays(-1)
            });

            // Act
            var booking = new BookingContract
            {
                Start    = DateTime.UtcNow.AddDays(1),
                Duration = 2,
                HotelId  = 1
            };
            var result = this.bookingService.Book(booking);

            // Assert
            var bookingEntity = this.repository.FirstOrDefault <Booking>(x => x.Id == result);

            Assert.IsNotNull(bookingEntity);
            Assert.AreEqual(booking.HotelId, bookingEntity.HotelId);
            Assert.AreEqual(booking.Start, bookingEntity.Start);
            Assert.AreEqual(booking.Start.AddDays(booking.Duration), bookingEntity.End);
        }
예제 #11
0
        /// <inheritdoc />
        public Task <Guid> AddBooking(BookingContract bookingContract)
        {
            var confirmation = await _bookingRepository.AddBooking(bookingContract);

            return(confirmation);
        }