Example #1
0
        public ActionResult Index(string searchQuery)
        {
            BookSearchResponse response = new BookSearchResponse();

            response.Query = searchQuery;
            try
            {
                response.Result = DatabaseHelper.GetBookBySubstring(searchQuery);
            }
            catch (Exception e)
            {
                response.Exception = e;
            }
            return(PartialView("_SearchResults", response));
        }
        /// <summary>
        /// 录单页面资源查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static BookSearchResponse GetHotelRuleList(int hotelid, int roomid)
        {
            var           response = new BookSearchResponse();
            StringBuilder sbwhere  = new StringBuilder();

            //酒店id
            sbwhere.AppendFormat(" AND  b.Id = {0}", hotelid);
            //房型id
            sbwhere.AppendFormat(" AND  r.Id = {0}", roomid);
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(@"SELECT
	                        b.Id AS HotelId,
	                        r.Id AS HotelRoomId,
	                        rr.Id AS HotelRoomRuleId,
	                        b.HIName AS HotelName,
	                        b.HIAddress AS HotelAddress,
	                        b.HILinkPhone AS HotelTel,
	                        r.HRName AS HotelRoomName,
	                        rr.HRRName AS HotelRoomRuleName,
	                        r.HRBedType AS HotelRoomBedType,
	                        rr.HRRBreakfastRuleName AS HotelRoomBreakfastRuleName,
	                        rr.HRRCancelRule AS HotelRoomCancelRule,
	                        rr.HRRCancelRuleName AS HotelRoomCancelRuleName,
	                        rr.HRRSourceId AS HotelSupplierSourceId,
	                        rr.HRRSourceName AS HotelSupplierSourceName,
	                        rr.HRRSupplierId AS HotelSupplierId,
	                        rr.HRRSupplierName AS HotelSupplierName
                        FROM
	                        h_hotelroomrule rr
                        INNER JOIN h_hotelroom r ON r.Id = rr.HRId
                        INNER JOIN h_hotelinfo b ON r.HIId = b.Id
                        WHERE
	                        1 = 1 {0}"    , sbwhere.ToString());

            var list = MysqlHelper.GetList <BookSearchResponse>(sb.ToString());

            return(list.FirstOrDefault());
        }
        /// <summary>
        /// 录单详情页酒店信息查询
        /// </summary>
        /// <param name="hid"></param>
        /// <param name="roomid"></param>
        /// <param name="ruleid"></param>
        /// <param name="supplierid"></param>
        /// <returns></returns>
        public static BookSearchResponse GetHotelRuleDetial(int hid, int roomid, int ruleid, int supplierid)
        {
            var           response = new BookSearchResponse();
            StringBuilder sb       = new StringBuilder();

            sb.Append(@"SELECT
	                            b.Id AS HotelId,
	                            r.Id AS HotelRoomId,
	                            rr.Id AS HotelRoomRuleId,
	                            b.HIName AS HotelName,
	                            b.HIAddress AS HotelAddress,
	                            b.HILinkPhone AS HotelTel,
	                            r.HRName AS HotelRoomName,
                                rr.HRRName AS HotelRoomRuleName,
	                            r.HRBedType AS HotelRoomBedType,
	                            rr.HRRBreakfastRuleName AS HotelRoomBreakfastRuleName,
	                            rr.HRRCancelRule AS HotelRoomCancelRule,
	                            rr.HRRCancelRuleName AS HotelRoomCancelRuleName,
	                            rr.HRRSourceId AS HotelSupplierSourceId,
	                            rr.HRRSourceName AS HotelSupplierSourceName,
	                            rr.HRRSupplierId AS HotelSupplierId,
	                            rr.HRRSupplierName AS HotelSupplierName,
	                            rp.HRPSellPrice AS HoteRoomRuleSellPrice,
	                            rp.HRPContractPrice AS HoteRoomRuleContractPrice,
	                            s.SSubWay AS HotelSupplierSubWay,
	                            s.SLinkMail AS HotelSupplierLinkMail
                            FROM
	                            h_hotelinfo b
                            INNER JOIN h_hotelroom r ON r.HIId = b.Id
                            INNER JOIN h_hotelroomrule rr ON r.Id = rr.HRId
                            INNER JOIN h_hoteruleprice rp ON rr.Id = rp.HRRId
                            INNER JOIN h_supplier s ON s.Id = rr.HRRSupplierId
                            WHERE
	                            b.HIIsValid = 1
                            AND r.HRIsValid = 1
                            AND rr.HRRIsValid = 1
                            AND rp.HRPIsValid = 1
                            AND s.SIsValid = 1");
            //酒店id
            if (hid > 0)
            {
                sb.AppendFormat(" AND  b.Id = {0}", hid);
            }
            //房间id
            if (roomid > 0)
            {
                sb.AppendFormat(" AND  r.Id = {0}", roomid);
            }
            //房型id
            if (ruleid > 0)
            {
                sb.AppendFormat(" AND  rr.Id = {0}", ruleid);
            }
            //供应商id
            if (ruleid > 0)
            {
                sb.AppendFormat(" AND  s.Id = {0}", supplierid);
            }
            var list = MysqlHelper.GetList <BookSearchResponse>(sb.ToString());

            if (list != null && list.Any())
            {
                response = list.FirstOrDefault();
            }
            return(response);
        }