Esempio n. 1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                Session["Active"] = "SearchBookingsList";

                _response    = _helper.SearchData();
                _currentData = SearchDataByCondition().ToList();
                if (!IsPostBack)
                {
                    Session["CurrentPage"] = 1;

                    BindRepeater(_currentData.Take(Constant.ItemPerPage));
                }
            }
            catch (Exception ex)
            {
                var logs = new Logs
                {
                    LogKey         = "Admin_SearchBookingPage_Error",
                    UpdatedBy      = PublicCustomerInfos != null ? PublicCustomerInfos.CustomerId : 1,
                    UpdatedDate    = DateTime.UtcNow,
                    UpdatedContent = string.Format("{0} - {1} - {2}", ex.Message, ex.StackTrace, ex.Source)
                };
                _helper.AddLog(logs);
            }
        }
Esempio n. 2
0
        public SearchDataResponse Search(string keyword = "", int page = 1)
        {
            IEnumerable <SearchResultItem> results = context.Database.SqlQuery <SearchResultItem>(
                "SELECT Title as Title,[cms_News].Id,ImagePath, 0 as 'Type'" +
                " FROM   cms_News inner join share_Images on cms_News.CoverImageId = share_Images.Id" +
                " WHERE  Title like '%" + keyword + "%'" +
                " UNION" +
                " SELECT Name as Title,[portal_Projects].Id,ImagePath, 1 as 'Type'" +
                " FROM   portal_Projects inner join share_Images on portal_Projects.CoverImageId = share_Images.Id" +
                " WHERE  Name like '%" + keyword + "%'"
                ).Skip((page - 1) * 8).Take(8).ToList().Cast <SearchResultItem>();
            int total = context.Database.SqlQuery <int>(
                "SELECT COUNT(*) " +
                " FROM(" +
                " SELECT Title as Title,[cms_News].Id,ImagePath, 0 as 'Type'" +
                " FROM   cms_News inner join share_Images on cms_News.CoverImageId = share_Images.Id" +
                " WHERE  Title like '%" + keyword + "%'" +
                " UNION" +
                " SELECT Name as Title,[portal_Projects].Id,ImagePath, 1 as 'Type'" +
                " FROM   portal_Projects inner join share_Images on portal_Projects.CoverImageId = share_Images.Id" +
                " WHERE  Name like '%" + keyword + "%'" +
                " )src"
                ).First();
            SearchDataResponse response = new SearchDataResponse()
            {
                TotalResult = total,
                Results     = results
            };

            return(response);
        }
Esempio n. 3
0
        public SearchResultResponse SeachData(string keyword, int?page)
        {
            SearchDataResponse   result   = _service.Search(keyword, (int)page);
            SearchResultResponse retValue = new SearchResultResponse()
            {
                Items      = result.Results.ConvertToSearchResultViewModels(),
                TotalItems = result.TotalResult
            };

            return(retValue);
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            Session["Active"] = "SearchBookingsList";

            int customerId;

            int.TryParse(Request.Params["id"], out customerId);
            CurrentCustomerId = customerId;
            if (!IsPostBack)
            {
                Session["CurrentPage"] = 1;
                CustomerInfosDetails   = _customerInfoRepository.GetById(CurrentCustomerId);

                string json = JsonConvert.SerializeObject(CustomerInfosDetails, CustomSettings.SerializerSettings());
                Session["CustomerInfosDetails"] = json;

                _response = _helper.SearchDataByCustomerId(CurrentCustomerId);

                _currentData = _response.ListBookingsData.ToList();
                string jsonData = JsonConvert.SerializeObject(_currentData, CustomSettings.SerializerSettings());
                Session["SearchCustomerBookings"] = jsonData;
                BindRepeater(_currentData.Take(10));
            }
            else
            {
                string session = Session["CustomerInfosDetails"] != null ? Session["CustomerInfosDetails"].ToString() : string.Empty;
                CustomerInfosDetails = JsonConvert.DeserializeObject <CustomerInfos>(session);

                string sessionData = Session["SearchCustomerBookings"] != null ? Session["SearchCustomerBookings"].ToString() : string.Empty;
                _currentData = JsonConvert.DeserializeObject <List <SearchDataObject> >(sessionData);
            }

            if (CustomerInfosDetails == null)
            {
                Response.Redirect(Constant.SearchBookingsAdminpage);
            }

            // Get Membership Info
            PublicDiscounts = _customerInfoRepository.GetSubscriptionDiscount(CustomerInfosDetails.CustomerId);

            if (PublicDiscounts != null)
            {
                _subscriptionBookings = _subscriptionBookingRepository.GetByCustomerId(CustomerInfosDetails.CustomerId, PublicDiscounts.Id);
                if (_subscriptionBookings != null && _subscriptionBookings.Status == (byte)Enums.SubscriptionBookingStatus.Active)
                {
                    CancelMembershipLinkButton.Visible = true;
                }
            }

            BindCustomerData();
        }