Example #1
0
        //public IList<RateTypeSearchResultDTO> getRateTypeBySearchCriteria(RateTypeSearchCriteriaDTO searchCriteria, PagingInformation pageInfo)
        //{
        //    IList<string> hotelCodeList = userAccountService.GetUserMappedHotelCodes(searchCriteria.UserName);
        //    if (hotelCodeList != null && hotelCodeList.Any())
        //    {
        //        List<RateType> rateTypeList = (from rt in ratetypeRepo.GetAll()
        //                                       where hotelCodeList.Contains(rt.HotelCode)
        //                                       select rt).ToList();

        //        //Hotel Name
        //        if (!string.IsNullOrWhiteSpace(searchCriteria.HotelName))
        //        {
        //            rateTypeList = rateTypeList.Where(p => p.HotelCode == searchCriteria.HotelName).ToList();
        //        }

        //        pageInfo.RecordsTotal = rateTypeList.Count();

        //        if (!string.IsNullOrWhiteSpace(pageInfo.OrderColumn))
        //        {
        //            string orderString = pageInfo.OrderColumn.TrimEnd(',');
        //            rateTypeList = rateTypeList.AsQueryable().OrderBy(orderString).ToList();
        //        }
        //        else
        //        {
        //            rateTypeList = rateTypeList.AsQueryable().OrderByDescending(p => p.ID).ToList();
        //        }

        //        //Setup paging
        //        if (pageInfo.PageSize == -1 && pageInfo.StartIndex == -1)
        //        {

        //        }
        //        else
        //        {
        //            rateTypeList = rateTypeList.AsQueryable().Skip(pageInfo.StartIndex).Take(pageInfo.PageSize).ToList();
        //        }
        //        //Get column that we need
        //        var list = rateTypeList.Select(x => new RateTypeSearchResultDTO()
        //        {
        //            id = x.ID,
        //            HotelCode = x.HotelCode,
        //            RateTypeCode = x.RateTypeCode,
        //            RateTypeCodeDescription = x.RateTypeCodeDescription,
        //            InsertDate = x.InsertDate,
        //            UpdateDate = x.UpdateDate,
        //            IsActive = x.ActiveYN

        //        }).ToList();

        //        return list;
        //    }
        //    else
        //        return null;
        //}

        public IList <RateTypeSearchResultDTO> getRateTypeBySearchCriteria(RateTypeSearchCriteriaDTO searchCriteria, PagingInformation pageInfo)
        {
            IList <RateTypeSearchResultDTO> list = ratetypeRepo.GetRateTypeBySearchCriteria(searchCriteria, pageInfo);
            var query = list.AsEnumerable();

            //Get all rateTypes
            pageInfo.RecordsTotal = query.Count();

            if (!string.IsNullOrWhiteSpace(pageInfo.OrderColumn))
            {
                var orderString = TransformOrder(pageInfo.OrderColumn.TrimEnd(','));
                query = query.OrderBy(orderString);
            }
            else
            {
                //query = query.OrderByDescending(p => p.id);
                query = query.OrderBy(p => p.HotelCode);
            }

            //Setup paging
            if (pageInfo.PageSize == -1 && pageInfo.StartIndex == -1)
            {
            }
            else
            {
                query = query.Skip(pageInfo.StartIndex).Take(pageInfo.PageSize);
            }

            return(query.ToList());
        }
Example #2
0
        public byte[] GenerateRateTypeExcelBySearchCriteria(RateTypeSearchCriteriaDTO searchCriteria, PagingInformation pageInfo)
        {
            //For excel export, we need to export all records.
            //So set the pageindex and pagesize to -1
            pageInfo.StartIndex = -1;
            pageInfo.PageSize   = -1;

            var list = getRateTypeBySearchCriteria(searchCriteria, pageInfo);
            //if (searchCriteria.HotelName == null)
            //{
            //    //Hotel List
            //    var hotelList = userAccountService.GetUserMappedHotels(searchCriteria.UserName);

            //    if (hotelList.Count > 1)
            //    {
            //        var secondHotelValue = hotelList[0].Value;
            //        int index = secondHotelValue.IndexOf('_');
            //        var secondDateFormat = secondHotelValue.Substring(index + 1);
            //        secondDateFormat = secondDateFormat.ToLower().Replace("m", "M");
            //        for (var i = 0; i < list.Count; i++)
            //        {
            //            list[i].DateFormat = secondDateFormat;
            //        }
            //    }
            //}
            //Get excel export list
            var excelList = mapper.Map <IList <RateTypeExportExcelModel> >(list);

            return(excelList.ToExcelContent());
        }
        public IList <RateTypeSearchResultDTO> GetRateTypeBySearchCriteria(RateTypeSearchCriteriaDTO searchCriteria, PagingInformation pageInfo)
        {
            List <RateTypeSearchResultDTO> list = new List <RateTypeSearchResultDTO>();

            try
            {
                string query = @" select ID = r.ID, 
                    HotelCode= r.HotelCode,
                    RateTypeCode = r.RateTypeCode, 
                    RateTypeCodeDescription= r.RateTypeCodeDescription, 
                    IsActive = r.ActiveYN, 
                    InsertDate = r.InsertDate, 
                    UpdateDate= r.UpdateDate,
                    DateFormat = h.DateFormat 
               from RateType r with(nolock) join Hotels h with (nolock) on r.HotelCode = h.Hotel_Code ";

                var subquery = "";
                //Hotel Name
                if (!string.IsNullOrWhiteSpace(searchCriteria.HotelName))
                {
                    subquery += string.Format("h.Hotel_Code = '{0}' and ", searchCriteria.HotelName);
                }
                else
                {
                    //Based on user hotel mapping to get back hotel list, then only show those hotels
                    subquery += string.Format(@"exists (select HotelCode from ConciergeHotelAccessMapping hm with (nolock)
	                    Where hm.ActiveYN = 1 and hm.HotelCode = r.HotelCode and hm.ConciergeID = N'{0}') and "    , searchCriteria.UserName);
                }

                if (!string.IsNullOrEmpty(subquery))
                {
                    subquery = subquery.Substring(0, subquery.Length - " and ".Length);
                    query   += " and (" + subquery + ")";
                }
                list = this.DataContext.Database.SqlQuery <RateTypeSearchResultDTO>(query).ToList();
            }
            catch (Exception ex)
            {
                var error = ex.Message;
            }
            return(list);
        }