public ReservationDetailViewModel(int hOfferId, int tOfferId)
 {
     _hOfferId                = hOfferId;
     _tOfferId                = tOfferId;
     HotelOffer               = new HotelOfferModel();
     TransportOffer           = new TransportOfferModel();
     SubmitReservationCommand = new Command(async(object context) => await MakeReservation(context));
 }
Beispiel #2
0
        public ActionResult Index(HotelOfferModel model)
        {
            using (HotelsOfferingActivities activities = new HotelsOfferingActivities())
            {
                var getOffersResult = activities.GetOffers(model.Filter, model.Sorting);

                return(View(getOffersResult.ReturnedObject));
            }
        }
        /// <summary>
        /// Get Offers from the service API, and do the needed filtering and sorting.
        /// </summary>
        /// <param name="filter">The filter of offers.</param>
        /// <param name="sorting">The sorting order.</param>
        /// <returns>
        /// An instance of the <see cref="T:Expedia.CodingExercise.DataType.ActivityResult"/> class.
        /// </returns>
        public ActivityResult GetOffers(HotelsOffersFilter filter, HotelsOffersSorting sorting)
        {
            /// <summary>
            /// Returned calss
            /// </summary>
            ActivityResult activityResult = new ActivityResult();

            /// <summary>
            /// The needed parameters to make the API request
            /// </summary>
            GetOffersRequest request = new GetOffersRequest(filter);

            try
            {
                using (HotelsOfferingDataSource dataSource = new HotelsOfferingDataSource())
                {
                    var offers = dataSource.GetOffers(request);

                    if (offers != null)
                    {
                        HotelOfferModel hotelOffersModel = new HotelOfferModel();
                        hotelOffersModel.Offers  = offers.GetHotelsOffersDetailsModel();
                        hotelOffersModel.Filter  = filter ?? new HotelsOffersFilter();
                        hotelOffersModel.Sorting = sorting ?? new HotelsOffersSorting();
                        if (sorting != null)
                        {
                            hotelOffersModel.Offers = hotelOffersModel.Offers.ApplyOrder(sorting.OrderBy);
                        }

                        activityResult.IsPassed       = true;
                        activityResult.ReturnedObject = hotelOffersModel;
                    }
                    else
                    {
                        activityResult.IsPassed = false;
                        activityResult.Code     = eResponseCode.General_Error;
                    }
                }
            }
            catch (Exception ex)
            {
                activityResult.IsPassed = false;
                activityResult.Code     = eResponseCode.General_Error;
            }

            return(activityResult);
        }
        public async Task Init()
        {
            try
            {
                var hOffer = await _hOfferService.GetById <HotelOfferDTO>(_hOfferId);

                var tOffer = await _tOfferService.GetById <TransportOfferDTO>(_tOfferId);


                var hotel = await _hotelService.GetById <HotelDTO>(hOffer.HotelId);

                var transportCompany = await _tCompanyService.GetById <TransportCompanyDTO>(tOffer.TransportCompanyId);

                HotelOffer = new HotelOfferModel {
                    hOffer = hOffer, Name = hotel.HotelName
                };
                TransportOffer = new TransportOfferModel {
                    tOffer = tOffer, Name = transportCompany.TransportCompanyName
                };
                //var hotelRoomsData = await _hRoomService.Get<List<HotelRoomsDTO>>(new HotelRoomsSearchRequest {HotelId = hotel.Id });
                //foreach (var hroom in hotelRoomsData)
                //{
                //    var roomTypeData = await _roomTypeService.GetById<RoomTypeDTO>(hroom.RoomTypeId );
                //    Rooms.Add(new RoomTypeModel {
                //        RoomTypeId =roomTypeData.Id,
                //        HotelId = hroom.HotelId,
                //        RoomTypeName = roomTypeData.RoomTypeName,
                //        RoomDetails = roomTypeData.RoomDetails,
                //        NumberOfRooms = hroom.NumberOfRooms,
                //        Available = hroom.Available,
                //        NumberOfPeople = roomTypeData.NumberOfPeople,
                //        Price = hroom.Price
                //    });
                //}
            }catch (Exception e)
            {
            }
        }
        //public ObservableCollection<RoomTypeModel> Rooms { get; set; }
        //= new ObservableCollection<RoomTypeModel>();

        public ReservationDetailViewModel()
        {
            HotelOffer               = new HotelOfferModel();
            TransportOffer           = new TransportOfferModel();
            SubmitReservationCommand = new Command(async(object context) => await MakeReservation(context));
        }