Exemplo n.º 1
0
 private void Nights_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (Nights.Validate())
     {
         EndDate.SelectedDate = StartDate.SelectedDate?.AddDays(Nights.IntValue);
     }
     Save.IsEnabled = IsSaveEnabled();
 }
Exemplo n.º 2
0
        public Nights ReadNightsFile()
        {
            FileStream    fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
            XmlSerializer reader     = new XmlSerializer(typeof(Nights));
            Nights        nights     = reader.Deserialize(fileStream) as Nights;

            fileStream.Flush();
            fileStream.Dispose();
            return(nights);
        }
Exemplo n.º 3
0
 public List <Night> GetLastTenNights(Nights nights)
 {
     nights.NightList.Sort(new NightRecentFirst());
     if (nights.NightList.Count > 10)
     {
         return(nights.NightList.Take(10).ToList());
     }
     else
     {
         return(nights.NightList);
     }
 }
Exemplo n.º 4
0
        public bool IsSaveEnabled()
        {
            bool validRoom      = Room.SelectedIndex > 0;
            bool validGuest     = GuestName.Validate();
            bool validGuests    = GuestsInRoom.Validate();
            bool validNights    = Nights.Validate();
            bool validTotal     = TotalPrice.Validate();
            bool validPaid      = PaidSum.Validate();
            bool validRemaining = RemainingSum.Validate();

            return(validRoom && validGuest && validGuests && validNights && validTotal && validPaid && validRemaining);
        }
Exemplo n.º 5
0
        public void WriteNewNightsFile(List <Night> nightList)
        {
            Nights nights = new Nights();

            nights.NightList = nightList;

            FileStream    fileStream = new FileStream(filename, FileMode.CreateNew);
            XmlSerializer writer     = new XmlSerializer(typeof(Nights));

            writer.Serialize(fileStream, nights);
            fileStream.Flush();
            fileStream.Dispose();
        }
Exemplo n.º 6
0
        public async Task UpdateBookingAsync()
        {
            using (var _clientProvider = new HttpClientProvider())
            {
                var uniquePartOfUri = Booking.Id;

                var newDates = new string[] { StartDate, Nights.ToString() };

                await AddAuthCookieAsync(_clientProvider.clientHandler);

                await GetCsrfToken(_clientProvider);

                await PutAsync($"{_uri}{uniquePartOfUri}", newDates, _clientProvider);

                await GetABookingAsync();
            }
        }
Exemplo n.º 7
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.History);
     txtTopTen             = FindViewById <TextView>(Resource.Id.txtViewTopTen);
     txtOverallMean        = FindViewById <TextView>(Resource.Id.txtOverallMean);
     txtWeekdayMean        = FindViewById <TextView>(Resource.Id.txtWeekdayMean);
     txtWeekendMean        = FindViewById <TextView>(Resource.Id.txtWeekendMean);
     txtPercentageLastWeek = FindViewById <TextView>(Resource.Id.txtPercentageLastWeek);
     txtPercentageAllTime  = FindViewById <TextView>(Resource.Id.txtPercentageAllTime);
     txtBestNight          = FindViewById <TextView>(Resource.Id.txtBestNight);
     txtWorstNight         = FindViewById <TextView>(Resource.Id.txtWorstNight);
     nights = logic.ReadNightsFile();
     BindLastTenNightsTxt();
     BindMeanTimes();
     BindPercentages();
     BindBest();
     BindWorst();
 }
Exemplo n.º 8
0
        public void WriteTestFile()
        {
            Nights nights = new Nights();

            nights.NightList = new List <Night>();
            for (int i = 1; i <= 7; i++)
            {
                Night night = new Night()
                {
                    StartTime = new DateTime(2018, 7, i, 20, 30, 00),
                    EndTime   = new DateTime(2018, 7, i + 1, 4 + i, 00, 00),
                };
                night.TimeSleptInMinutes = night.EndTime.Subtract(night.StartTime).TotalMinutes;
                nights.NightList.Add(night);
            }
            FileStream    fileStream = new FileStream(filename, FileMode.OpenOrCreate);
            XmlSerializer writer     = new XmlSerializer(typeof(Nights));

            writer.Serialize(fileStream, nights);
            fileStream.Flush();
            fileStream.Dispose();
        }
Exemplo n.º 9
0
        public async Task BookAccommodationAsync()
        {
            using (var _clientProvider = new HttpClientProvider())
            {
                var uniquePartOfUri = "book";

                var bookingInfo = new string[] { StartDate, Booking.BookedBy.Id.ToString(), Nights.ToString(), Booking.Accommodation.Id.ToString() };

                await AddAuthCookieAsync(_clientProvider.clientHandler);

                await GetCsrfToken(_clientProvider);

                await PostAsync($"{_uri}{uniquePartOfUri}", bookingInfo, _clientProvider);
            }
        }
Exemplo n.º 10
0
    public QueryStringParametrs(HttpRequest request)
    {
        _request = request;
        var queryString = _request.QueryString;

        if (!queryString.HasKeys())
        {
            IsEmpty          = true;
            IsParametrsValid = false;
            return;
        }

        IsParametrsValid = true;
        IsEmpty          = true;

        try
        {
            // todo: доделать обработку обязательных параметров в строке запроса.
            var strPrmValues = queryString["country"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                CountryToKey = int.Parse(strPrmValues);
            }

            strPrmValues = queryString["departFrom"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                CityFromKey = int.Parse(strPrmValues);
            }


            strPrmValues = queryString["tourtype"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                TourTypeKeys = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = queryString["city"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                CitiesToKeys = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = queryString["tour"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                TourKeys = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = queryString["dateFrom"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                ArrivalDateFrom = DateTime.Parse(strPrmValues);
            }
            strPrmValues = queryString["dateTo"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                if (ArrivalDateFrom.HasValue)
                {
                    ArrivalDateTo = DateTime.Parse(strPrmValues);
                }
                else
                {
                    throw new FormatException("QueryString parametr dateTo mast be used with parametr dateFrom");
                }
            }
            else
            {
                if (ArrivalDateFrom.HasValue)
                {
                    throw new FormatException("QueryString parametr dateFrom mast be used with parametr dateTo");
                }
            }

            strPrmValues = queryString["nights"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                Nights = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = WebUtility.UrlDecode(queryString["stars"]);
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                HotelCategoriesKeys = strPrmValues.Split(',').ToArray();
            }

            strPrmValues = queryString["pansion"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                PansionKeys = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = queryString["filterHotelsArrNights"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                IsHotelsFiltredByArrNights = bool.Parse(strPrmValues);
            }

            strPrmValues = queryString["hotel"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                HotelKeys = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = queryString["room"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                RoomTypeKeys = strPrmValues.Split(',').Select(int.Parse).ToArray();
            }

            strPrmValues = queryString["adults"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                AdultsNumber = ushort.Parse(strPrmValues);
            }
            strPrmValues = queryString["childs"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                ChildsNumber = ushort.Parse(strPrmValues);
            }
            strPrmValues = queryString["firstChildAge"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                FirstChildAge = ushort.Parse(strPrmValues);
            }
            strPrmValues = queryString["secondChildAge"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                SecondChildAge = ushort.Parse(strPrmValues);
            }

            strPrmValues = queryString["aviaQuotaMask"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                QuotesStates tmp;
                if (!Enum.TryParse(strPrmValues, true, out tmp))
                {
                    throw new FormatException("aviaQuotaMask querystring parametr is wrong.");
                }
                AviaQuotesStates = tmp | QuotesStates.None;
            }

            strPrmValues = queryString["hotelQuotaMask"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                QuotesStates tmp;
                if (!Enum.TryParse(strPrmValues, true, out tmp))
                {
                    throw new FormatException("hotelQuotaMask querystring parametr is wrong.");
                }
                RoomsQuotesStates = tmp;
            }

            strPrmValues = queryString["currency"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                RateKey = int.Parse(strPrmValues);
            }
            strPrmValues = queryString["priceLimit"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                MaxPrice = uint.Parse(strPrmValues);
            }
            strPrmValues = queryString["pageSize"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                RowsNumber = ushort.Parse(strPrmValues);
            }
            strPrmValues = queryString["showResults"];
            if (!String.IsNullOrWhiteSpace(strPrmValues))
            {
                ShowResults = bool.Parse(strPrmValues);
            }
        }
        catch (FormatException e)
        {
            IsEmpty          = false;
            IsParametrsValid = false;
            return;
        }

        IsEmpty =
            !(CityFromKey.HasValue || CountryToKey.HasValue || (TourTypeKeys != null && TourTypeKeys.Any()) ||
              (CitiesToKeys != null && CitiesToKeys.Any()) || (TourKeys != null && TourKeys.Any()) ||
              (ArrivalDateFrom.HasValue && ArrivalDateTo.HasValue) || (Nights != null && Nights.Any()) ||
              (HotelCategoriesKeys != null && HotelCategoriesKeys.Any()) || (PansionKeys != null && PansionKeys.Any()) ||
              (HotelKeys != null && HotelKeys.Any()) || (RoomTypeKeys != null && RoomTypeKeys.Any()) ||
              AdultsNumber.HasValue || ChildsNumber.HasValue || FirstChildAge.HasValue || SecondChildAge.HasValue ||
              AviaQuotesStates.HasValue || RoomsQuotesStates.HasValue || RateKey.HasValue || MaxPrice.HasValue || RowsNumber.HasValue || ShowResults.HasValue);
    }