public static string CheckConserveCommissionHotelMapping(int id, string MapHotels)
        {
            string s = "";

            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                try
                {
                    eConserveCommission eCC  = GetSingleRecordById(id);
                    List <string>       htls = MapHotels.Split(',').ToList();

                    var data = (from a in db.tblConserveCommissionMs.Where(u => u.iCCId != id && u.dtFrom <= eCC.dtTo && u.dtTo >= eCC.dtFrom && u.cStatus == "A")
                                join PPM in db.tblPropConserveCommissionMaps on a.iCCId equals PPM.iCCId into PPM1
                                from PPM2 in PPM1.DefaultIfEmpty()
                                join Prop in db.tblPropertyMs on PPM2.iPropId equals Prop.iPropId into Properties
                                from Property in Properties.DefaultIfEmpty()
                                select new
                    {
                        a.iCCId,
                        Property.sHotelName,
                        Property.iPropId
                    }).Distinct().OrderBy(u => u.iCCId).AsQueryable().ToList();

                    if (data != null && data.Count > 0)
                    {
                        StringBuilder SS = new StringBuilder();
                        int           i  = 0;
                        SS.Append("");
                        foreach (var item in data)
                        {
                            if (htls.Contains(item.iPropId.ToString()))
                            {
                                if (i < 10)
                                {
                                    SS.Append(item.sHotelName + " (" + item.iPropId.ToString() + ")" + " is mapped with conserve commission ID : " + item.iCCId.ToString() + ".<br>");
                                    i++;
                                }
                                else
                                {
                                    SS.Append("And more...");
                                    break;
                                }
                            }
                        }
                        s = SS.ToString();
                    }
                }
                catch (Exception) { }
            }
            return(s);
        }
Beispiel #2
0
        //Get list of records
        public static List <ePromoCodeDisp> getRecordForSearch(OneFineRateAppUtil.jQueryDataTableParamModel param, out int TotalCount)
        {
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                List <ePromoCodeDisp> Promolst = new List <ePromoCodeDisp>();
                param.sSearch = param.sSearch == null ? "" : param.sSearch;
                var objTblPromo = (from a in db.tblPromoCodeMs
                                   join c in db.tblUserMs on a.iActionBy equals c.iUserId into PC
                                   from T in PC.DefaultIfEmpty()
                                   join am in db.tblAmenityMs on a.iAmenityId equals am.iAmenityId into S2
                                   from am1 in S2.DefaultIfEmpty()
                                   join PPM in db.tblPropertyPromoMaps on a.iPromoCodeId equals PPM.iPromoCodeId into PPM1
                                   from PPM2 in PPM1.DefaultIfEmpty()
                                   select new
                {
                    a.iPromoCodeId,
                    a.sPromoCode,
                    a.sPromoTitle,
                    a.sPromoDescription,
                    sAmenityName = am1.sAmenityName == null || am1.sAmenityName == "" ? (a.cPercentageValue == "1" ? a.dValue.ToString() + " %" : "Value: " + a.dValue.ToString()) : am1.sAmenityName,
                    a.dtBookingFrom,
                    a.dtBookingTo,
                    a.dtStayFrom,
                    a.dtStayTo,
                    a.dtActionDate,
                    cStatus = a.cStatus == "A" ? "Live" : "Disable",
                    ActionBy = T.sFirstName + " " + T.sLastName,
                    HotelCount = PPM1.Count()
                }).Distinct().Where(u => u.sPromoCode.Contains(param.sSearch) || u.sPromoTitle.Contains(param.sSearch)).AsQueryable();

                //get Total Count for show total records
                TotalCount = objTblPromo.Count();

                //for sorting
                switch (param.iSortingCols)
                {
                case 0:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.sPromoCode) : objTblPromo.OrderByDescending(u => u.sPromoCode);
                    break;

                case 3:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.dtBookingFrom) : objTblPromo.OrderByDescending(u => u.dtBookingFrom);
                    break;

                case 4:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.dtBookingTo) : objTblPromo.OrderByDescending(u => u.dtBookingTo);
                    break;

                case 5:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.dtStayFrom) : objTblPromo.OrderByDescending(u => u.dtStayFrom);
                    break;

                case 6:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.dtStayTo) : objTblPromo.OrderByDescending(u => u.dtStayTo);
                    break;

                case 7:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.cStatus) : objTblPromo.OrderByDescending(u => u.cStatus);
                    break;

                case 8:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.ActionBy) : objTblPromo.OrderByDescending(u => u.ActionBy);
                    break;

                case 9:
                    objTblPromo = param.sortDirection == "asc" ? objTblPromo.OrderBy(u => u.dtActionDate) : objTblPromo.OrderByDescending(u => u.dtActionDate);
                    break;
                }

                ////implemented paging
                var lstUser = objTblPromo.Skip(param.iDisplayStart).Take(param.iDisplayLength).ToList();

                //convert bll entity object to db entity object
                foreach (var item in lstUser)
                {
                    Promolst.Add((ePromoCodeDisp)OneFineRateAppUtil.clsUtils.ConvertToObject(item, new ePromoCodeDisp()));
                }
                return(Promolst);
            }
        }
    { //Get list of records
        public static List <eConserveCommissionDisp> getRecordForSearch(OneFineRateAppUtil.jQueryDataTableParamModel param, out int TotalCount)
        {
            using (OneFineRateEntities db = new OneFineRateEntities())
            {
                List <eConserveCommissionDisp> CClst = new List <eConserveCommissionDisp>();
                param.sSearch = param.sSearch == null ? "" : param.sSearch;
                var objTblCC = (from a in db.tblConserveCommissionMs
                                join c in db.tblUserMs on a.iActionBy equals c.iUserId into PC
                                from T in PC.DefaultIfEmpty()
                                join PPM in db.tblPropConserveCommissionMaps on a.iCCId equals PPM.iCCId into PPM1
                                from PPM2 in PPM1.DefaultIfEmpty()
                                select new
                {
                    a.iCCId,
                    a.dCommission,
                    a.dtFrom,
                    a.dtTo,
                    bDisplayRateComm = (bool)a.bDisplayRateComm ? "Yes" : "No",
                    bBidComm = (bool)a.bBidComm ? "Yes" : "No",
                    bCOComm = (bool)a.bCOComm ? "Yes" : "No",
                    dCounterTrigger = (bool)a.bCOComm ? a.dCounterTrigger : 0,
                    a.dtActionDate,
                    cStatus = a.cStatus == "A" ? "Live" : "Disable",
                    ActionBy = T.sFirstName + " " + T.sLastName,
                    HotelCount = PPM1.Count()
                }).Distinct().AsQueryable();

                //get Total Count for show total records
                TotalCount = objTblCC.Count();

                //for sorting
                switch (param.iSortingCols)
                {
                case 0:
                    objTblCC = param.sortDirection == "asc" ? objTblCC.OrderBy(u => u.iCCId) : objTblCC.OrderByDescending(u => u.iCCId);
                    break;

                case 6:
                    objTblCC = param.sortDirection == "asc" ? objTblCC.OrderBy(u => u.dtFrom) : objTblCC.OrderByDescending(u => u.dtFrom);
                    break;

                case 7:
                    objTblCC = param.sortDirection == "asc" ? objTblCC.OrderBy(u => u.dtTo) : objTblCC.OrderByDescending(u => u.dtTo);
                    break;

                case 8:
                    objTblCC = param.sortDirection == "asc" ? objTblCC.OrderBy(u => u.cStatus) : objTblCC.OrderByDescending(u => u.cStatus);
                    break;
                }

                ////implemented paging
                var lstUser = objTblCC.Skip(param.iDisplayStart).Take(param.iDisplayLength).ToList();

                //convert bll entity object to db entity object
                foreach (var item in lstUser)
                {
                    CClst.Add((eConserveCommissionDisp)OneFineRateAppUtil.clsUtils.ConvertToObject(item, new eConserveCommissionDisp()));
                }
                return(CClst);
            }
        }