protected void Search_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(DateFrom.Text) || string.IsNullOrEmpty(DateTo.Text))
            {
                return;
            }
            List <Bookings> bookings;
            DateTime        startDate;

            DateTime.TryParseExact(DateFrom.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out startDate);
            DateTime endDate;

            DateTime.TryParseExact(DateTo.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out endDate);
            var searchBookingsParams = new SearchBookingsParams
            {
                HotelId             = PublicHotel.HotelId,
                StartDate           = startDate,
                EndDate             = endDate,
                IsBookingForRevenue = false
            };

            bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);

            ListDates = Helper.GetDateRanges(startDate, endDate);
            BindEngagement(bookings);
        }
Beispiel #2
0
        protected void Search_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(DateFrom.Text) || string.IsNullOrEmpty(DateTo.Text))
            {
                return;
            }
            List <Bookings> bookings;
            DateTime        startDate;

            DateTime.TryParseExact(DateFrom.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out startDate);
            DateTime endDate;

            DateTime.TryParseExact(DateTo.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out endDate);
            var searchBookingsParams = new SearchBookingsParams
            {
                HotelId             = _hotels.HotelId,
                StartDate           = startDate,
                EndDate             = endDate,
                IsBookingForRevenue = true
            };

            bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
            FilterBookingByProductType(ref bookings);
            BindRevenue(bookings);
        }
        protected void SearchBooking(object sender, EventArgs e)
        {
            DateTime startDate;
            var      searchBookingsParams = new SearchBookingsParams
            {
                HotelId             = _hotels.HotelId,
                IsBookingForRevenue = false,
                FilterText          = SearchText.Text.Trim()
            };

            switch (SelectedFilterDdl.SelectedValue)
            {
            case "All":
                var searchAllParam = new SearchAllBookingsParams
                {
                    HotelId      = _hotels.HotelId,
                    IsForRevenue = false,
                    FilterText   = SearchText.Text.Trim()
                };
                _bookings = _bookingRepository.GetAllBookingsOfHotel(searchAllParam);
                break;

            case "Today":
                var searchTodayParam = new SearchAllBookingsTodayParams
                {
                    HotelId      = _hotels.HotelId,
                    IsForRevenue = false
                };
                _bookings = _bookingRepository.GetAllBookingsToday(searchTodayParam);
                break;

            case "ThisWeek":
                startDate = DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).StartOfWeek(DayOfWeek.Monday);
                searchBookingsParams.StartDate = startDate;
                searchBookingsParams.EndDate   = startDate.AddDays(6);
                _bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                break;

            case "ThisMonth":
                startDate = new DateTime(DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Year,
                                         DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Month, 1);
                searchBookingsParams.StartDate = startDate;
                searchBookingsParams.EndDate   = startDate.AddDays(DateTime.DaysInMonth(startDate.Year, startDate.Month) - 1);
                _bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                break;

            case "Custom":
                DateTime.TryParseExact(DateFrom.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out startDate);
                DateTime endDate;
                DateTime.TryParseExact(DateTo.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out endDate);
                searchBookingsParams.StartDate  = startDate;
                searchBookingsParams.EndDate    = endDate;
                searchBookingsParams.FilterText = SearchText.Text.Trim();
                _bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                break;
            }

            Session["CurrentPage"] = 1;
            BindRepeater(_bookings.Take(Constant.ItemPerPage).ToList());
        }
        protected void Search_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(DateFrom.Text) || string.IsNullOrEmpty(DateTo.Text))
            {
                return;
            }
            DateTime startDate;

            DateTime.TryParseExact(DateFrom.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out startDate);
            DateTime endDate;

            DateTime.TryParseExact(DateTo.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out endDate);
            var searchBookingsParams = new SearchBookingsParams
            {
                HotelId             = _hotels.HotelId,
                StartDate           = startDate,
                EndDate             = endDate,
                IsBookingForRevenue = false,
                FilterText          = SearchText.Text.Trim()
            };

            _bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);

            Session["CurrentPage"] = 1;
            BindRepeater(_bookings.Take(Constant.ItemPerPage).ToList());
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                Session["Active"] = "CustomerInsight";
                var searchAllParam = new SearchAllBookingsParams
                {
                    HotelId      = PublicHotel.HotelId,
                    IsForRevenue = true
                };
                var result = _bookingRepository.GetAllBookingsOfHotel(searchAllParam);
                if (result.Count >= AppConfiguration.MininumItemToCalculateRevenue)
                {
                    MVEngagement.ActiveViewIndex = 1;
                }
                else
                {
                    MVEngagement.ActiveViewIndex = 0;
                }
                if (!IsPostBack)
                {
                    SelectedFilterBy.Text = SelectedFilterDdl.SelectedItem.Text;
                    ProductTypeLabel.Text = ProductTypeDdl.Text;

                    DateTime endDate   = DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId);
                    var      startDate = new DateTime(DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Year,
                                                      DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Month, 1);
                    var searchBookingsParams = new SearchBookingsParams
                    {
                        HotelId             = PublicHotel.HotelId,
                        StartDate           = startDate,
                        EndDate             = endDate,
                        IsBookingForRevenue = false
                    };
                    var bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);

                    ListDates = Helper.GetDateRanges(startDate, endDate);

                    BindEngagement(bookings);
                }
            }
            catch (Exception ex)
            {
                var logs = new Logs
                {
                    LogKey         = "Admin_EngagementPage_Error",
                    UpdatedBy      = 1,
                    UpdatedDate    = DateTime.UtcNow,
                    UpdatedContent = string.Format("{0} - {1} - {2}", ex.Message, ex.StackTrace, ex.Source)
                };
                _bookingRepository.AddLog(logs);
            }
        }
        private void ReCalculateEngagement()
        {
            var bookings = new List <Bookings>();

            DateFrom.Visible   = false;
            DateTo.Visible     = false;
            Search.Visible     = false;
            CustomForm.Visible = false;
            DateTime startDate;
            DateTime endDate = DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId);
            var      searchBookingsParams = new SearchBookingsParams
            {
                HotelId             = PublicHotel.HotelId,
                IsBookingForRevenue = false
            };

            switch (SelectedFilterDdl.SelectedValue)
            {
            case "All":
                var searchAllParam = new SearchAllBookingsParams
                {
                    HotelId      = PublicHotel.HotelId,
                    IsForRevenue = false
                };
                bookings = _bookingRepository.GetAllBookingsOfHotel(searchAllParam);
                var firstDate = bookings.Where(x => x.RedeemedDate.HasValue).Min(x => x.RedeemedDate.Value).ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId);
                var lastDate  = bookings.Where(x => x.RedeemedDate.HasValue).Max(x => x.RedeemedDate.Value).ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId);

                ListDates = Helper.GetDateRanges(firstDate, lastDate);
                break;

            case "Today":
                ListDates = new List <DateTime>
                {
                    DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId)
                };
                var searchTodayParam = new SearchAllBookingsTodayParams
                {
                    HotelId      = PublicHotel.HotelId,
                    IsForRevenue = false
                };
                bookings = _bookingRepository.GetAllBookingsToday(searchTodayParam);
                break;

            case "ThisWeek":
                startDate = DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).StartOfWeek(DayOfWeek.Monday);
                searchBookingsParams.StartDate = startDate;
                searchBookingsParams.EndDate   = endDate;
                bookings  = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                ListDates = Helper.GetDateRanges(startDate, endDate);
                break;

            case "ThisMonth":
                startDate = new DateTime(DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Year,
                                         DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Month, 1);
                searchBookingsParams.StartDate = startDate;
                searchBookingsParams.EndDate   = endDate;
                bookings  = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                ListDates = Helper.GetDateRanges(startDate, endDate);
                break;

            case "Custom":
                DateFrom.Visible   = true;
                DateTo.Visible     = true;
                Search.Visible     = true;
                CustomForm.Visible = true;
                ListDates          = new List <DateTime>();
                break;
            }
            SelectedFilterBy.Text = SelectedFilterDdl.SelectedItem.Text;
            ProductTypeLabel.Text = ProductTypeDdl.SelectedItem.Text;
            FilterBookingByProductType(ref bookings);
            BindEngagement(bookings);
        }
Beispiel #7
0
        private void ReCalculateRevenues()
        {
            var bookings = new List <Bookings>();

            DateFrom.Visible   = false;
            DateTo.Visible     = false;
            Search.Visible     = false;
            CustomForm.Visible = false;
            DateTime startDate;
            var      searchBookingsParams = new SearchBookingsParams
            {
                HotelId             = _hotels.HotelId,
                IsBookingForRevenue = true
            };

            switch (SelectedFilterDdl.SelectedValue)
            {
            case "All":
                var searchAllParam = new SearchAllBookingsParams
                {
                    HotelId      = _hotels.HotelId,
                    IsForRevenue = true
                };
                bookings = _bookingRepository.GetAllBookingsOfHotel(searchAllParam);
                break;

            case "Today":
                var searchTodayParam = new SearchAllBookingsTodayParams
                {
                    HotelId      = _hotels.HotelId,
                    IsForRevenue = true
                };
                bookings = _bookingRepository.GetAllBookingsToday(searchTodayParam);
                break;

            case "ThisWeek":
                startDate = DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).StartOfWeek(DayOfWeek.Monday);
                searchBookingsParams.StartDate = startDate;
                searchBookingsParams.EndDate   = startDate.AddDays(6);
                bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                break;

            case "ThisMonth":
                startDate = new DateTime(DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Year,
                                         DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Month, 1);
                searchBookingsParams.StartDate = startDate;
                searchBookingsParams.EndDate   = startDate.AddDays(DateTime.DaysInMonth(startDate.Year, startDate.Month) - 1);
                bookings = _bookingRepository.GetAllbookingsByRange(searchBookingsParams);
                break;

            case "Custom":
                DateFrom.Visible   = true;
                DateTo.Visible     = true;
                Search.Visible     = true;
                CustomForm.Visible = true;
                break;
            }
            SelectedFilterBy.Text = SelectedFilterDdl.SelectedItem.Text;
            ProductTypeLabel.Text = ProductTypeDdl.SelectedItem.Text;
            FilterBookingByProductType(ref bookings);
            BindRevenue(bookings);
        }
        private List <Bookings> GetBookingByCurrentCondition()
        {
            var      bookings = new List <Bookings>();
            DateTime startDate;
            var      param = new SearchBookingsParams
            {
                HotelId    = _hotels.HotelId,
                FilterText = SearchText.Text.Trim()
            };

            switch (SelectedFilterDdl.SelectedValue)
            {
            case "All":
                var searchAllParam = new SearchAllBookingsParams
                {
                    HotelId      = _hotels.HotelId,
                    IsForRevenue = false,
                    FilterText   = SearchText.Text.Trim()
                };
                bookings = _bookingRepository.GetAllBookingsOfHotel(searchAllParam);
                break;

            case "Today":
                var searchTodayParam = new SearchAllBookingsTodayParams
                {
                    HotelId      = _hotels.HotelId,
                    IsForRevenue = false
                };
                bookings = _bookingRepository.GetAllBookingsToday(searchTodayParam);
                break;

            case "ThisWeek":
                startDate                 = DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).StartOfWeek(DayOfWeek.Monday);
                param.StartDate           = startDate;
                param.EndDate             = startDate.AddDays(6);
                param.IsBookingForRevenue = false;
                bookings = _bookingRepository.GetAllbookingsByRange(param);
                break;

            case "ThisMonth":
                startDate = new DateTime(DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Year,
                                         DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Month, 1);
                param.StartDate           = startDate;
                param.EndDate             = startDate.AddDays(DateTime.DaysInMonth(startDate.Year, startDate.Month) - 1);
                param.IsBookingForRevenue = false;
                bookings = _bookingRepository.GetAllbookingsByRange(param);
                break;

            case "Custom":
                DateTime endDate;
                if (string.IsNullOrEmpty(DateFrom.Text) || !DateTime.TryParseExact(DateFrom.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out startDate))
                {
                    MessageLabel.Text = "Please enter From and To date.";
                    return(bookings);
                }
                if (string.IsNullOrEmpty(DateTo.Text) || !DateTime.TryParseExact(DateTo.Text, "MM/dd/yyyy", null, DateTimeStyles.None, out endDate))
                {
                    MessageLabel.Text = "Please enter From and To date.";
                    return(bookings);
                }
                param.StartDate           = startDate;
                param.EndDate             = endDate;
                param.IsBookingForRevenue = false;
                bookings = _bookingRepository.GetAllbookingsByRange(param);
                break;
            }

            return(bookings);
        }