Exemplo n.º 1
0
        private string InsertHotel(OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType hotel)
        {
            string returnVal = string.Empty;

            using (var context = new TravelDBContext())
            {
                Hotel h         = null;
                int   hotelCode = Convert.ToInt32(hotel.HotelCode);
                var   isHas     = (from e in context.Hotels where e.HotelCode == hotelCode select e).ToList();
                if (isHas.Count > 0)
                {
                    returnVal = isHas[0].Id;
                    h         = isHas[0];
                }
                else
                {
                    h    = new Hotel();
                    h.Id = CommonUtil.GetHotelID(hotelCode);
                }

                h.BrandCode      = Convert.ToInt32(hotel.BrandCode);
                h.LastMofifyTime = DateTime.Now;
                h.AreaID         = Convert.ToInt32(hotel.AreaID);
                h.HotelCityCode  = Convert.ToInt32(hotel.HotelCityCode);
                h.HotelCode      = Convert.ToInt32(hotel.HotelCode);
                h.HotelName      = hotel.HotelName;

                var hoteinfo = hotel.HotelInfo;
                if (Check(hoteinfo))
                {
                    if (hoteinfo[0].LastUpdated != null)
                    {
                        h.LastUpdated = Convert.ToDateTime(hoteinfo[0].LastUpdated);
                    }
                    else
                    {
                        h.LastUpdated = null;
                    }

                    if (hoteinfo[0].WhenBuilt != null)
                    {
                        h.WhenBuilt = Convert.ToDateTime(hoteinfo[0].WhenBuilt);
                    }
                    else
                    {
                        h.WhenBuilt = null;
                    }
                }

                if (isHas.Count == 0)
                {
                    returnVal = context.Hotels.Add(h).Id;
                }

                context.SaveChanges();
                LoggerHelper(hotelCode.ToString(), "HotelName : " + h.HotelName + ",Updated/Inserted");

                return(returnVal);
            }
        }
Exemplo n.º 2
0
        public static HtmlString SelectImg(this IHtmlHelper html, int idTour)
        {
            string result = "";

            using (TravelDBContext travelDB = new TravelDBContext())
            {
                Tour  tour  = travelDB.Tour.FirstOrDefault(t => t.Id == idTour);
                Hotel hotel = travelDB.Hotel.FirstOrDefault(h => h.Id == tour.IdHotel);
                IEnumerable <Picture> pictures = travelDB.Picture.Where(p => p.IdHotel == hotel.Id);

                if (pictures.Count() != 0)
                {
                    foreach (Picture picture in pictures)
                    {
                        result += "" +
                                  "<div class='img_select'>" +
                                  "<img src = '" + picture.NamePicture + "' class='img_slide'>" +
                                  "</div>";
                    }
                }
                else
                {
                    result = "Pictures are not founded!";
                }
            }

            return(new HtmlString(result));
        }
Exemplo n.º 3
0
        public static HtmlString GetIndicator(this IHtmlHelper html, Hotel hotel)
        {
            string result = "";

            using (TravelDBContext travelDB = new TravelDBContext())
            {
                int number = 0;
                IEnumerable <Picture> pictures = travelDB.Picture.Where(p => p.IdHotel == hotel.Id);
                string classPicture            = "active";

                if (pictures.Count() == 1)
                {
                    result = "<li data-target='#myCarousel' data-slide-to='" + number + "' class='" + classPicture + "'></ li > ";
                }
                else
                {
                    foreach (Picture picture in pictures)
                    {
                        if (picture.Id == hotel.IdPicture)
                        {
                            classPicture = "active";
                        }
                        else
                        {
                            classPicture = "";
                        }

                        result += "<li data-target='#myCarousel' data-slide-to='" + number + "' class='" + classPicture + "'></ li > ";
                        number++;
                    }
                }
            }

            return(new HtmlString(result));
        }
Exemplo n.º 4
0
        public IActionResult GetItineraryByTraveller([FromBody] ItineraryByTravellerInputParamModel searchItirneraryParam)
        {
            try
            {
                var travelDb       = new TravelDBContext();
                var TravelerFlight = travelDb.TravelData.Include(g => g.FlightItineraries);

                if (searchItirneraryParam.Email == null && searchItirneraryParam.Passport == null)
                {
                    return(Ok(TravelerFlight.Select(t => Mapper.Map(t)).ToArray()));
                }
                if (searchItirneraryParam.Email != null && searchItirneraryParam.Passport == null)
                {
                    //Busca por email
                    return(Ok(TravelerFlight.Where(tf => tf.Email == searchItirneraryParam.Email).Select(t => Mapper.Map(t)).ToArray()));
                }
                if (searchItirneraryParam.Email == null && searchItirneraryParam.Passport != null)
                {
                    return(Ok(TravelerFlight.Where(tf => tf.Passport == searchItirneraryParam.Passport).Select(t => Mapper.Map(t)).ToArray()));
                }
                if (searchItirneraryParam.Email != null && searchItirneraryParam.Passport != null)
                {
                    return(Ok(TravelerFlight.Where(tf => tf.Email == searchItirneraryParam.Email && tf.Passport == searchItirneraryParam.Passport).Select(t => Mapper.Map(t)).ToArray()));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                return(NotFound(ex));
            }
        }
Exemplo n.º 5
0
        public static HtmlString GetCountries(this IHtmlHelper html)
        {
            string result = "";

            using (TravelDBContext travelDB = new TravelDBContext())
            {
                IEnumerable <Country> countries = travelDB.Country;

                if (countries.Count() != 0)
                {
                    foreach (Country country in countries)
                    {
                        result += "" +
                                  "<div class='country'>" +
                                  "<h3>" + country.NameCountry + "</h3>" +
                                  "</div>" +
                                  "<div class='aboutCountryTours' style='display: none;'>" +
                                  "<div class='row tour'>" +
                                  GetTours(html, country) +
                                  "</div>" +
                                  "</div>";
                    }
                }
                else
                {
                    result = "Countries is not founded!";
                }
            }

            return(new HtmlString(result));
        }
Exemplo n.º 6
0
        private void InsertPosition(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.HotelInfoLocalType.PositionLocalType> Position)
        {
            if (Position != null)
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <Position> EfContext = new EfRepository <Position>(context);

                    var positions = (from p in EfContext.Table where p.HotelID == hotelId select p).ToList();
                    if (positions != null)
                    {
                        EfContext.Delete(positions);
                    }

                    IList <Position> ps = new List <Position>();

                    foreach (var item in Position)
                    {
                        Position p = new Model.Position();
                        p.HotelID          = hotelId;
                        p.Latitude         = Convert.ToDecimal(item.Latitude);
                        p.Longitude        = Convert.ToDecimal(item.Longitude);
                        p.PositionTypeCode = Convert.ToInt32(item.PositionTypeCode);
                        p.LastMofifyTime   = DateTime.Now;
                        LoggerHelper(hotelCode, "Position " + p.Latitude + "," + p.Longitude + "," + "Inserted");
                        ps.Add(p);
                    }

                    EfContext.Insert(ps);
                    LoggerHelper(hotelCode, "Position Inserted Finished");
                }
            }
        }
Exemplo n.º 7
0
        public void ProcessPrice(string hotelId, string hotelCode, string xml, bool ifNeedUpdateRatePlan, bool isInitilize)
        {
            //XRoot root = XRoot.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "realprice.xml"));
            XRoot root = XRoot.Parse(xml);

            var RatePlans = root.Response.HotelResponse[0].OTA_HotelRatePlanRS.RatePlans;

            foreach (var item in RatePlans)
            {
                if (ifNeedUpdateRatePlan)
                {
                    using (var context = new TravelDBContext())
                    {
                        EfRepository <RatePlan> ratePlanContext = new EfRepository <RatePlan>(context);

                        var rpCheck = (from r in ratePlanContext.Table where r.HoteID == hotelId select r).ToList();
                        if (rpCheck.Count > 0)
                        {
                            ratePlanContext.Delete(rpCheck);
                        }
                    }
                }
                // var hotelCode = item.HotelCode;
                ProcessRatePlan(hotelId, item.RatePlan, ifNeedUpdateRatePlan, isInitilize);
            }


            //Console.Read();
        }
Exemplo n.º 8
0
        private void InsertBookingRules(int ratePlanId, IList <BookingRules> BooKRules)
        {
            if (Check(BooKRules))
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <BookRule> bookruleContext = new EfRepository <BookRule>(context);
                    EfRepository <RoomPlanBookRuleMapping> roomPlanBookMappingContext = new EfRepository <RoomPlanBookRuleMapping>(context);

                    var mappingCheck = (from m in roomPlanBookMappingContext.Table where m.RatePlanId == ratePlanId select m).ToList();
                    if (mappingCheck.Count > 0)
                    {
                        roomPlanBookMappingContext.Delete(mappingCheck);
                    }



                    foreach (var item in BooKRules[0].BookingRule)
                    {
                        if (item.MinAdvancedBookingOffset != null)
                        {
                            string key = "MinAdvancedBookingOffset";
                            InsertBookRuleMapping(ratePlanId, key, item.MinAdvancedBookingOffset, roomPlanBookMappingContext, bookruleContext);
                        }


                        if (Check(item.LengthsOfStay))
                        {
                            foreach (var los in item.LengthsOfStay)
                            {
                                string key = "LengthOfStay";
                                InsertBookRuleMapping(ratePlanId, key, los.LengthOfStay[0].Time, roomPlanBookMappingContext, bookruleContext);

                                Console.WriteLine(los.LengthOfStay[0].Time);
                            }
                        }

                        if (item.LaterReserveTime != null)
                        {
                            string key = "LaterReserveTime";
                            InsertBookRuleMapping(ratePlanId, key, item.LaterReserveTime, roomPlanBookMappingContext, bookruleContext);
                        }


                        if (Check(item.Viewerships))
                        {
                            string key      = "Viewerships";
                            string customer = string.Empty;
                            foreach (var vs in item.Viewerships[0].Viewership)
                            {
                                var Customer = vs.Profiles[0].Profile[0].Customer[0].CustomerValue;
                                customer += Customer + ",";
                            }

                            InsertBookRuleMapping(ratePlanId, key, customer, roomPlanBookMappingContext, bookruleContext);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void InsertOffers(int ratePlanId, IList <OTA_HotelRatePlanRS.RatePlansLocalType.RatePlanLocalType.OffersLocalType> offers)
        {
            if (Check(offers))
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <Offer>     offerContext     = new EfRepository <Offer>(context);
                    EfRepository <OfferRule> offerRuleContext = new EfRepository <OfferRule>(context);

                    Int32 offerInserted = -1;
                    foreach (var offer in offers[0].Offer)
                    {
                        Offer offerModel = new Offer();
                        offerModel.OfferCode = Convert.ToInt32(offer.OfferCode);

                        var description = offer.OfferDescription;

                        if (Check(description))
                        {
                            var descriptionText = description[0].Text;
                            offerModel.OfferDescription = descriptionText;
                        }

                        var discounts = offer.Discount;
                        if (Check(discounts))
                        {
                            var discount = discounts[0];
                            offerModel.NightsDiscounted = Convert.ToInt32(discount.NightsDiscounted);
                            offerModel.NightsRequired   = Convert.ToInt32(discount.NightsRequired);
                            offerModel.DiscountPattern  = discount.DiscountPattern;
                        }
                        offerModel.ratePlanId = ratePlanId;

                        offerContext.Insert(offerModel);
                        LoggerHelper(ratePlanId, " Offer" + description + "Inserted");

                        offerInserted = offerModel.Id;

                        var offerRules = offer.OfferRules;
                        if (Check(offerRules) && Check(offerRules[0].OfferRule[0].DateRestriction))
                        {
                            foreach (var item in offerRules[0].OfferRule[0].DateRestriction)
                            {
                                OfferRule or = new OfferRule();
                                or.RestrictionDateCode = Convert.ToInt32(item.RestrictionDateCode);
                                or.LastModifyTime      = DateTime.Now;
                                or.OfferId             = offerInserted;
                                or.EndTime             = item.End;
                                or.StartTime           = item.Start;
                                or.RestrictionType     = item.RestrictionType;

                                offerRuleContext.Insert(or);
                                LoggerHelper(ratePlanId, " Offer Rule" + or.RestrictionDateCode + "Inserted");
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void InsertAreaInfo(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.AreaInfoLocalType> areas)
        {
            if (Check(areas))
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <RefPoint> refPointContext = new EfRepository <RefPoint>(context);
                    EfRepository <REF>      refContext      = new EfRepository <REF>(context);

                    var refPoingCheck = (from p in refPointContext.Table where p.HotelID == hotelId select p).ToList();
                    if (refPoingCheck.Count > 0)
                    {
                        refPointContext.Delete(refPoingCheck);
                    }

                    var refPoints = areas[0].RefPoints;

                    foreach (var item in refPoints[0].RefPoint)
                    {
                        var Distance          = item.Distance;
                        int UnitOfMeasureCode = Convert.ToInt32(item.UnitOfMeasureCode);
                        var Name                 = item.Name;
                        var Latitude             = item.Latitude;
                        var Longitude            = item.Longitude;
                        int RefPointCategoryCode = Convert.ToInt32(item.RefPointCategoryCode);
                        var RefPointName         = item.RefPointName;
                        var DescriptiveText      = item.DescriptiveText;

                        var refCheck = (from f in refContext.Table where f.Id == RefPointCategoryCode select f).ToList();
                        if (refCheck.Count == 0)
                        {
                            REF r = new REF();
                            r.Id            = RefPointCategoryCode;
                            r.Name          = RefPointName;
                            r.LastModiyTime = DateTime.Now;
                            refContext.Insert(r);
                        }

                        RefPoint rp = new RefPoint();
                        rp.HotelID        = hotelId;
                        rp.Distance       = Convert.ToDecimal(Distance);
                        rp.Name           = Name;
                        rp.REFINT         = RefPointCategoryCode;
                        rp.UOMID          = UnitOfMeasureCode;
                        rp.LastMofifyTime = DateTime.Now;

                        refPointContext.Insert(rp);

                        LoggerHelper(hotelCode, "RefPoing Name: " + Name + " Inserted");
                        Console.WriteLine();
                    }
                }
            }
        }
Exemplo n.º 11
0
 public IActionResult GetTravels()
 {
     try
     {
         var travelDb = new TravelDBContext();
         var travels  = travelDb.Travels;
         return(Ok(travels.Select(t => Mapper.Map(t)).ToArray()));
     }
     catch (Exception ex)
     {
         return(NotFound(ex));
     }
 }
Exemplo n.º 12
0
        private void InsertAffiliation(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.AffiliationInfoLocalType> affiliation)
        {
            if (Check(affiliation))
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <AwardType>         awardContext = new EfRepository <AwardType>(context);
                    EfRepository <HotelAwardMapping> awardMapping = new EfRepository <HotelAwardMapping>(context);

                    var awardMappingCheck = (from a in awardMapping.Table where a.HotelID == hotelId select a).ToList();
                    if (awardMappingCheck.Count > 0)
                    {
                        awardMapping.Delete(awardMappingCheck);
                    }

                    foreach (var item in affiliation[0].Awards[0].Award)
                    {
                        int AID        = -1;
                        var awardCheck = (from a in awardContext.Table where a.Name == item.Provider select a).ToList();
                        if (awardCheck.Count == 0)
                        {
                            AwardType at = new AwardType();
                            at.Name           = item.Provider;
                            at.LastMofifyTime = DateTime.Now;

                            awardContext.Insert(at);
                            AID = at.Id;
                        }
                        else
                        {
                            AID = awardCheck.FirstOrDefault().Id;
                        }

                        HotelAwardMapping ham = new HotelAwardMapping();
                        ham.AwardID        = AID;
                        ham.HotelID        = hotelId;
                        ham.LastMofifyTime = DateTime.Now;
                        ham.Rating         = Convert.ToDecimal(item.Rating);

                        awardMapping.Insert(ham);

                        LoggerHelper(hotelCode, "Award Name: " + item.Provider + "," + item.Rating + " Inserted");
                    }
                }
            }
        }
Exemplo n.º 13
0
 public IActionResult DeleteTravelData([FromBody] TravelDataDeleteInputParamModel travelDataInput)
 {
     try
     {
         var travelDb = new TravelDBContext();
         travelDb.TravelData.Remove(new TravelDatum()
         {
             Id = travelDataInput.TravelDataId
         });
         travelDb.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         return(NotFound(ex));
     }
 }
Exemplo n.º 14
0
        public ActionResult Login(Account account)
        {
            if (ModelState.IsValid)
            {
                using (TravelDBContext db = new TravelDBContext())
                {
                    var result = db.Accounts.Where(x => x.userName.Equals(account.userName) &&
                                                   x.password.Equals(account.password)).FirstOrDefault();

                    if (result != null)
                    {
                        Session["userName"] = result.userName.ToString();
                        return(RedirectToAction("AdminDashBoard"));
                    }
                }
            }
            return(View(account));
        }
Exemplo n.º 15
0
        public string GetHotelIdByCode(int hotelCode)
        {
            using (var context = new TravelDBContext())
            {
                using (var tran = context.Database.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted))
                {
                    var isHas = (from e in context.Hotels where e.HotelCode == hotelCode select e).ToList();
                    tran.Commit();

                    if (isHas.Count > 0)
                    {
                        return(isHas.First().Id);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void ProcessRatePlan(string hoteId, IList <OTA_HotelRatePlanRS.RatePlansLocalType.RatePlanLocalType> ratePlans, bool ifNeedUpdateRatePlan, bool isInitilize)
        {
            if (Check(ratePlans))
            {
                foreach (var item in ratePlans)
                {
                    int RatePlanId = -1;
                    using (var context = new TravelDBContext())
                    {
                        int ratePlanCode = Convert.ToInt32(item.RatePlanCode);

                        EfRepository <RatePlan> ratePlanContext = new EfRepository <RatePlan>(context);

                        var rpCheck = (from r in ratePlanContext.Table where r.HoteID == hoteId && r.RatePlanCode == ratePlanCode select r).ToList();
                        if (rpCheck.Count > 0)
                        {
                            RatePlanId = rpCheck.First().Id;
                        }
                        else
                        {
                            RatePlan rp = new RatePlan();
                            rp.RatePlanCategory = item.RatePlanCategory;
                            rp.IsCommissionable = Convert.ToBoolean(item.IsCommissionable);
                            rp.LastModifyTime   = DateTime.Now;
                            rp.MarketCode       = item.MarketCode;
                            rp.RatePlanCode     = ratePlanCode;
                            rp.RateReturn       = Convert.ToBoolean(item.RateReturn);
                            rp.HoteID           = hoteId;


                            ratePlanContext.Insert(rp);
                            RatePlanId = rp.Id;
                        }
                    }

                    InsertRate(RatePlanId, item.Rates, !isInitilize);
                    InsertOffers(RatePlanId, item.Offers);
                    InsertBookingRules(Convert.ToInt32(RatePlanId), item.BookingRules);
                }
            }
        }
Exemplo n.º 17
0
        public IActionResult InsertUpdateTravelData([FromBody] TravelDataModel travelDataInput)
        {
            try
            {
                var travelDb = new TravelDBContext();
                if (travelDb.TravelData.Where(td => td.TravelId == travelDataInput.TravelId).Any())
                {
                    //Si no esta la persona (unico por pasaporte) entonces lo agrego, sino lo actualizo
                    if (!travelDb.TravelData.Where(td => td.TravelId == travelDataInput.TravelId && td.Passport == travelDataInput.Passport).Any())
                    {
                        //Agregar
                        travelDb.TravelData.Add(Mapper.Map(travelDataInput));
                        travelDb.SaveChanges();
                        SendEmailToCompleteInsertOrUpdate(travelDataInput);
                        return(Ok());
                    }
                    else
                    {
                        //Actualizar
                        var traveldataToUpdate = travelDb.TravelData.Where(td => td.TravelId == travelDataInput.TravelId && td.Passport == travelDataInput.Passport).SingleOrDefault();
                        traveldataToUpdate.PassengerName = travelDataInput.PassengerName;
                        traveldataToUpdate.Birthdate     = travelDataInput.Birthdate;
                        traveldataToUpdate.Email         = travelDataInput.Email;
                        travelDb.SaveChanges();

                        SendEmailToCompleteInsertOrUpdate(travelDataInput);

                        return(Ok());
                    }
                }
                else
                {
                    return(Ok("No existe el viaje"));
                }
            }
            catch (Exception ex)
            {
                return(NotFound(ex));
            }
        }
Exemplo n.º 18
0
        public static HtmlString GetCarousel(this IHtmlHelper html, Hotel hotel)
        {
            string result = "";

            using (TravelDBContext travelDB = new TravelDBContext())
            {
                IEnumerable <Picture> pictures = travelDB.Picture.Where(p => p.IdHotel == hotel.Id);
                string classPicture            = "active";

                if (pictures.Count() == 1)
                {
                    result = "" +
                             "<div class='item " + classPicture + " slide'>" +
                             "<img src = '" + pictures.FirstOrDefault().NamePicture + "' class='img_slide'>" +
                             "</div>";
                }
                else
                {
                    foreach (Picture picture in pictures)
                    {
                        if (picture.Id == hotel.IdPicture)
                        {
                            classPicture = "active";
                        }
                        else
                        {
                            classPicture = "";
                        }

                        result += "" +
                                  "<div class='item " + classPicture + " slide'>" +
                                  "<img src = '" + picture.NamePicture + "' class='img_slide'>" +
                                  "</div>";
                    }
                }
            }

            return(new HtmlString(result));
        }
Exemplo n.º 19
0
        private void InsertSEG(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.HotelInfoLocalType.CategoryCodesLocalType> SEG)
        {
            if (SEG != null)
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <CategoryCodeHotelMapping> EfContext = new EfRepository <CategoryCodeHotelMapping>(context);

                    var seg = (from s in EfContext.Table where s.HotelId == hotelId select s).ToList();

                    if (seg != null)
                    {
                        EfContext.Delete(seg);
                    }

                    IList <CategoryCodeHotelMapping> segs = new List <CategoryCodeHotelMapping>();

                    foreach (var item in SEG)
                    {
                        CategoryCodeHotelMapping s = new CategoryCodeHotelMapping();
                        int segID = Convert.ToInt32(item.SegmentCategory[0].Code);



                        s.HotelId        = hotelId;
                        s.SEGID          = segID;
                        s.LastMofifyTime = DateTime.Now;
                        segs.Add(s);

                        LoggerHelper(hotelCode, "Seg ID:" + segID + " Inserted");
                    }

                    EfContext.Insert(segs);

                    LoggerHelper(hotelCode, "Seg Inserte Finished");
                }
            }
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            string path         = AppDomain.CurrentDomain.BaseDirectory + "Code List.xls";
            var    excelFile    = new ExcelQueryFactory(path);
            var    artistAlbums = (from a in excelFile.WorksheetRangeNoHeader("B8", "C1257", "Codelists") select a).ToList();
            string tableName    = string.Empty;

            foreach (var a in artistAlbums)
            {
                if (!string.IsNullOrWhiteSpace(a[0]))
                {
                    int s;

                    if (Int32.TryParse(a[0], out s))
                    {
                        try
                        {
                            using (var context = new TravelDBContext())
                            {
Rego:

                                string checkTableSql = string.Format("select 1 from  sysobjects  where  id = object_id('[dbo].[{0}]')  and   type = 'U'", tableName);

                                object checkTableExsits = context.Database.SqlQuery <object>(checkTableSql).FirstOrDefault();

                                if (checkTableExsits != null)
                                {
                                    string checkSql = string.Format("select 1 from {0} where Id=@p0 and Name=@p1", tableName, a[0], a[1]);

                                    object exsits = context.Database.SqlQuery <object>(checkSql, a[0].Value, a[1].Value).FirstOrDefault();


                                    //delete
                                    //{
                                    //    string sql = "delete from {0}";

                                    //    context.Database.ExecuteSqlCommand(string.Format(sql, tableName, a[0], a[1]), a[0].Value, a[1].Value);
                                    //    Console.WriteLine(tableName + "," + a[0] + "," + a[1]);
                                    //}

                                    //insert

                                    if (exsits == null)
                                    {
                                        // string sql = "delete from {0}";
                                        string sql = "insert into {0} values (@p0,@p1,'" + DateTime.Now + "')";
                                        context.Database.ExecuteSqlCommand(string.Format(sql, tableName, a[0], a[1]), a[0].Value, a[1].Value);
                                        Console.WriteLine(tableName + "," + a[0] + "," + a[1]);
                                    }
                                }
                                else
                                {
                                    string createTableSql = string.Format("create table {0} (Id int primary key ,Name nvarchar(500) , LastModiyTime datetime) ", tableName);

                                    string sqlPath = "c:\\sql\\" + tableName + ".sql";

                                    if (!System.IO.File.Exists(sqlPath))
                                    {
                                        System.IO.File.AppendAllText(sqlPath, createTableSql);
                                    }
                                    //string createTableSql = string.Format("drop table {0}", tableName);
                                    context.Database.ExecuteSqlCommand(createTableSql);

                                    Console.WriteLine(tableName + "created");

                                    goto Rego;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                    else
                    {
                        tableName = a[0];
                    }
                }
            }

            Console.WriteLine("Done!");
            Console.Read();
        }
Exemplo n.º 21
0
        private void InsertAddress(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.HotelInfoLocalType.AddressLocalType> Address)
        {
            if (Address != null)
            {
                using (var context = new TravelDBContext())
                {
                    //using (TransactionScope tran = new TransactionScope())
                    {
                        EfRepository <Address>          addressContext          = new EfRepository <Address>(context);
                        EfRepository <AddressExtension> addressExtensionContext = new EfRepository <AddressExtension>(context);
                        EfRepository <Zone>             zoonContext             = new EfRepository <Zone>(context);
                        EfRepository <ZoneHotelMapping> zonehoteMappingContext  = new EfRepository <ZoneHotelMapping>(context);

                        var addressList = (from a in addressContext.Table where a.HotelID == hotelId select a).ToList();

                        if (addressList.Count > 0)
                        {
                            foreach (var al in addressList)
                            {
                                var addressExtension = addressExtensionContext.Table.Where(a => a.AddressID.Value == al.Id).ToList();
                                if (addressExtension.Count > 0)
                                {
                                    addressExtensionContext.Delete(addressExtension);
                                    LoggerHelper(hotelCode, "Hotel AddressExtensions Deleted");
                                }

                                var zoonhoteMapping = zonehoteMappingContext.Table.Where(z => z.HotelID == hotelId).ToList();
                                if (zoonhoteMapping.Count > 0)
                                {
                                    zonehoteMappingContext.Delete(zoonhoteMapping);
                                    LoggerHelper(hotelCode, "Hotel Zoon Deleted");
                                }
                            }


                            addressContext.Delete(addressList);
                            LoggerHelper(hotelCode, "Hotel Address Deleted");
                        }



                        foreach (var item in Address)
                        {
                            string addressLine = item.AddressLine;
                            string cityName    = item.CityName;
                            string postalCode  = item.PostalCode;

                            Address address = new Model.Address();
                            address.HotelID        = hotelId;
                            address.AddressLine    = addressLine;
                            address.CityName       = cityName;
                            address.PostalCode     = postalCode;
                            address.LastModifyTime = DateTime.Now;

                            addressContext.Insert(address);

                            LoggerHelper(hotelCode, addressLine);

                            int addressPK = address.Id;



                            var zone = item.Zone;
                            if (zone != null)
                            {
                                foreach (var z in zone)
                                {
                                    int  zCode          = Convert.ToInt32(z.ZoneCode);
                                    bool checkZoneExits = zoonContext.Table.Where(zm => zm.Id == zCode).Any();
                                    if (!checkZoneExits)
                                    {
                                        Zone zm = new Zone();
                                        zm.Id             = zCode;
                                        zm.Name           = z.ZoneName;
                                        zm.LastMofifyTime = DateTime.Now;
                                        zoonContext.Insert(zm);

                                        LoggerHelper(hotelCode, "zoon:" + z.ZoneName + "deleted");
                                    }

                                    ZoneHotelMapping zhm = new ZoneHotelMapping();
                                    zhm.HotelID        = hotelId;
                                    zhm.ZoneID         = zCode;
                                    zhm.LastMofifyTime = DateTime.Now;

                                    zonehoteMappingContext.Insert(zhm);

                                    LoggerHelper(hotelCode, "zoon:" + z.ZoneName);
                                }
                            }

                            var extension = item.TPA_Extensions;
                            if (extension != null && extension.Count > 0)
                            {
                                foreach (var e in extension)
                                {
                                    Console.WriteLine("AddressExternsion :" + e.RoadCross[0].DescriptionText);

                                    AddressExtension ae = new AddressExtension();
                                    ae.AddressID      = addressPK;
                                    ae.Description    = e.RoadCross[0].DescriptionText;
                                    ae.LastModifyTime = DateTime.Now;

                                    addressExtensionContext.Insert(ae);
                                    LoggerHelper(hotelCode, "addressExtension:" + ae.Description + "Inserted");
                                }
                            }
                        }


                        // tran.Complete();
                    }
                }
            }
        }
Exemplo n.º 22
0
        private void InsertServices(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.HotelInfoLocalType.ServicesLocalType> Services)
        {
            if (Check(Services))
            {
                using (var context = new TravelDBContext())
                {
                    //using (TransactionScope tran = new TransactionScope())
                    {
                        EfRepository <HACHATMapping> hachatContext = new EfRepository <HACHATMapping>(context);
                        EfRepository <HAT>           hatContext    = new EfRepository <HAT>(context);
                        EfRepository <HAC>           hacContext    = new EfRepository <HAC>(context);

                        var hachatlist = (from h in hachatContext.Table where h.HotelID == hotelId select h).ToList();

                        if (hachatlist.Count > 0)
                        {
                            hachatContext.Delete(hachatlist);
                            LoggerHelper(hotelCode, "Service Deleted");
                        }


                        foreach (var item in Services[0].Service)
                        {
                            if (string.IsNullOrEmpty(item.Code)) //may be empty
                            {
                                item.Code = "-1";
                            }

                            if (string.IsNullOrEmpty(item.ID)) //may be empty
                            {
                                item.ID = "-1";
                            }

                            int HACID = Convert.ToInt32(item.Code);

                            string descriptiveText = item.DescriptiveText;


                            var hacList = (from h in hacContext.Table where h.Id == HACID select h).ToList();

                            if (hacList.Count == 0)
                            {
                                HAC hac = new HAC();
                                hac.Id   = HACID;
                                hac.Name = descriptiveText;

                                hac.LastModiyTime = DateTime.Now;

                                hacContext.Insert(hac);
                            }

                            int HATID = Convert.ToInt32(item.ID);

                            var hatList = (from h in hatContext.Table where h.Id == HATID select h).ToList();

                            if (hatList.Count == 0)
                            {
                                HAT hac = new HAT();
                                hac.Id   = HATID;
                                hac.Name = "NO";

                                hac.LastModiyTime = DateTime.Now;

                                hatContext.Insert(hac);
                            }



                            HACHATMapping hachatmapping = new HACHATMapping();
                            hachatmapping.HACID           = Convert.ToInt32(HACID);
                            hachatmapping.HATID           = Convert.ToInt32(HATID);
                            hachatmapping.HotelID         = hotelId;
                            hachatmapping.LastModifyTine  = DateTime.Now;
                            hachatmapping.DescriptionText = descriptiveText; //use this value to  display

                            LoggerHelper(hotelCode, "Service,HacID/HATID" + HACID + "/" + HATID + "Inserted");
                            hachatContext.Insert(hachatmapping);
                        }

                        //tran.Complete();
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void InsertGuestRoom(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.FacilityInfoLocalType.GuestRoomsLocalType> GuestRooms)
        {
            if (GuestRooms != null && GuestRooms.Count > 0)
            {
                using (var context = new TravelDBContext())
                {
                    // TransactionOptions transactionOption = new TransactionOptions();
                    //  transactionOption.Timeout = new TimeSpan(0, 0, 600);

                    // using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required, transactionOption))
                    {
                        EfRepository <GuestRoom> guestRoomContext = new EfRepository <GuestRoom>(context);

                        EfRepository <RoomExtension>  roomExtensionsContext = new EfRepository <RoomExtension>(context);
                        EfRepository <RMARoomMapping> rmaRoomMappingContext = new EfRepository <RMARoomMapping>(context);
                        EfRepository <RMA>            rmaContext            = new EfRepository <RMA>(context);

                        int Inserted       = 0;
                        var guestRoomCheck = (from r in guestRoomContext.Table where r.HotelID == hotelId select r).ToList();

                        if (guestRoomCheck.Count > 0)
                        {
                            foreach (var item in guestRoomCheck)
                            {
                                var roomExtensions = (from e in roomExtensionsContext.Table where e.RoomID == item.Id select e).ToList();
                                if (roomExtensions.Count > 0)
                                {
                                    roomExtensionsContext.Delete(roomExtensions);
                                    LoggerHelper(hotelCode, "roomExtension  " + item.Name + " deleted");
                                }
                                var rmaRoomMapping = (from r in rmaRoomMappingContext.Table where r.RoomID == item.Id select r).ToList();
                                if (rmaRoomMapping.Count > 0)
                                {
                                    rmaRoomMappingContext.Delete(rmaRoomMapping);
                                    LoggerHelper(hotelCode, "roomMapping  " + item.Name + "  deleted");
                                }

                                guestRoomContext.Delete(item);
                                LoggerHelper(hotelCode, "GuestRoom " + item.Name + "  deleted");
                            }
                        }

                        foreach (var item in GuestRooms[0].GuestRoom)
                        {
                            string roomName = item.RoomTypeName;

                            var typeName = item.TypeRoom;
                            if (Check(typeName))
                            {
                                var    typeNameNode      = typeName[0];
                                int    StandardOccupancy = Convert.ToInt32(typeNameNode.StandardOccupancy);
                                string Size         = typeNameNode.Size;
                                string Name         = typeNameNode.Name;
                                string RoomTypeCode = typeNameNode.RoomTypeCode;
                                string Floor        = typeNameNode.Floor;
                                string InvBlockCode = typeNameNode.InvBlockCode;
                                string BedTypeCode  = typeNameNode.BedTypeCode;
                                string NonSmoking   = typeNameNode.NonSmoking;
                                string HasWindow    = typeNameNode.HasWindow;
                                string Quantity     = typeNameNode.Quantity;
                                string RoomSize     = typeNameNode.RoomSize;


                                GuestRoom gr = new GuestRoom();
                                gr.StandardOccupancy = StandardOccupancy;
                                gr.Size           = Size;
                                gr.Name           = Name;
                                gr.RoomTypeCode   = Convert.ToInt32(RoomTypeCode);
                                gr.Floor          = Floor;
                                gr.InvBlockCode   = Convert.ToInt32(InvBlockCode);
                                gr.BedTypeCode    = Convert.ToInt32(BedTypeCode);
                                gr.NonSmoking     = NonSmoking == "false" ? 0 : 1;
                                gr.HasWindow      = Convert.ToInt32(HasWindow);
                                gr.Quantity       = Convert.ToInt32(Quantity);
                                gr.RoomSize       = RoomSize;
                                gr.LastMofifyTime = DateTime.Now;
                                gr.HotelID        = hotelId;


                                var feature = item.Features;
                                if (Check(feature))
                                {
                                    gr.FeatureDescription = feature[0].Feature[0].DescriptiveText;
                                }
                                guestRoomContext.Insert(gr);

                                Inserted = gr.Id;
                                LoggerHelper(hotelCode, "GuestRoom " + Name + "  Inserted");
                            }

                            var Amenities = item.Amenities;
                            if (Check(Amenities))
                            {
                                foreach (var amentity in Amenities[0].Amenity)
                                {
                                    int    RoomAmenityCode = Convert.ToInt32(amentity.RoomAmenityCode);
                                    string DescriptiveText = amentity.DescriptiveText;

                                    var rmaCheck = (from r in rmaContext.Table where r.Id == RoomAmenityCode select r).ToList();
                                    if (rmaCheck.Count == 0)
                                    {
                                        RMA r = new RMA();
                                        r.Id            = RoomAmenityCode;
                                        r.Name          = DescriptiveText;
                                        r.LastModiyTime = DateTime.Now;

                                        rmaContext.Insert(r);
                                    }

                                    RMARoomMapping rmaRoomMapping = new RMARoomMapping();
                                    rmaRoomMapping.RMAID          = RoomAmenityCode;
                                    rmaRoomMapping.RoomID         = Inserted;
                                    rmaRoomMapping.LastMofifyTime = DateTime.Now;

                                    rmaRoomMappingContext.Insert(rmaRoomMapping);
                                    LoggerHelper(hotelCode, "Guest Amentity " + RoomAmenityCode + "," + DescriptiveText + "  Inserted");
                                }
                            }

                            var TPA_Extensions = item.TPA_Extensions;
                            if (Check(TPA_Extensions))
                            {
                                foreach (var extension in TPA_Extensions[0].TPA_Extension)
                                {
                                    string        FacilityName  = extension.FacilityName;
                                    string        FTypeName     = extension.FTypeName;
                                    string        FacilityValue = extension.FacilityValue;
                                    string        isAvailable   = extension.FacilityValue;
                                    RoomExtension re            = new RoomExtension();
                                    re.FacilityName   = FacilityName;
                                    re.FaciliTypeName = FTypeName;
                                    re.LastMofifyTime = DateTime.Now;
                                    re.IsAllAvailable = Convert.ToInt32(isAvailable);
                                    re.RoomID         = Inserted;

                                    roomExtensionsContext.Insert(re);
                                    LoggerHelper(hotelCode, "Room Extensions Inserted " + FacilityName + "  Inserted");
                                }
                            }
                        }

                        //tran.Complete();
                    }
                }
            }
        }
Exemplo n.º 24
0
        private void InsertPolicy(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.PoliciesLocalType.PolicyLocalType> policy)
        {
            if (Check(policy))
            {
                using (var context = new TravelDBContext())
                {
                    EfRepository <Policy>     policyContext     = new EfRepository <Policy>(context);
                    EfRepository <PolicyInfo> policyinfoContext = new EfRepository <PolicyInfo>(context);

                    var policyCheck = (from p in policyContext.Table where p.HotelID == hotelId select p).ToList();
                    if (policyCheck.Count > 0)
                    {
                        LoggerHelper(hotelCode, "Policy Deleted");
                        policyContext.Delete(policyCheck);
                    }

                    var policyinfoCheck = (from p in policyinfoContext.Table where p.HotelId == hotelId select p).ToList();
                    if (policyinfoCheck.Count > 0)
                    {
                        LoggerHelper(hotelCode, "policyinfo Deleted");
                        policyinfoContext.Delete(policyinfoCheck);
                    }



                    var policyinfoCodes = policy[0].PolicyInfoCodes;

                    if (Check(policyinfoCodes))
                    {
                        var PolicyInfoCode = policyinfoCodes[0].PolicyInfoCode;
                        foreach (var item in PolicyInfoCode[0].Description)
                        {
                            Console.WriteLine(item.Name + "," + item.Text);

                            Policy p = new Policy();
                            p.HotelID        = hotelId;
                            p.Key            = item.Name;
                            p.Value          = item.Text;
                            p.LastMofifyTime = DateTime.Now;

                            policyContext.Insert(p);
                        }
                    }

                    var policyinfo = policy[0].PolicyInfo;
                    if (policyinfo != null)
                    {
                        var CheckinTime  = policyinfo[0].CheckInTime;
                        var checkOutTime = policyinfo[0].CheckOutTime;

                        PolicyInfo pi = new PolicyInfo();
                        pi.HotelId        = hotelId;
                        pi.CheckIn        = CheckinTime;
                        pi.CheckOut       = checkOutTime;
                        pi.LastModifyTime = DateTime.Now;

                        policyinfoContext.Insert(pi);
                    }
                }
            }
        }
Exemplo n.º 25
0
        public static HtmlString GetTours(this IHtmlHelper html, Country country)
        {
            string result = "";

            using (TravelDBContext travelDB = new TravelDBContext())
            {
                try
                {
                    IEnumerable <Hotel>   hotels   = travelDB.Hotel.Where(h => h.IdCountry == country.Id);
                    IEnumerable <Tour>    tours    = travelDB.Tour;
                    IEnumerable <Picture> pictures = travelDB.Picture;
                    int num = 0;

                    foreach (Hotel h in hotels)
                    {
                        foreach (Tour t in tours)
                        {
                            if (t.IdHotel == h.Id)
                            {
                                num++;
                            }
                        }
                    }

                    if (num != 0)
                    {
                        foreach (Hotel hotel in hotels)
                        {
                            foreach (Tour tour in tours.Where(t => t.IdHotel == hotel.Id))
                            {
                                Picture currentPictures = pictures.FirstOrDefault(p => p.Id == hotel.IdPicture);
                                result += "" +
                                          "<div class='col-sm-6 col-md-4'>" +
                                          "<div class='thumbnail'>" +
                                          "<img src = '" + currentPictures.NamePicture + "' alt='" + currentPictures.NamePicture + "'>" +
                                          "<div class='caption'>" +
                                          "<h4>" + hotel.NameHotel + "</h4>" +
                                          "<h5>" + tour.DateArrival.GetValueOrDefault().ToShortDateString() + "</h5>" +
                                          "<p>" + hotel.Price + "$</p>" +
                                          "<p>" + tour.AmountDay + " days</p>" +
                                          "<p>" + tour.Cost(hotel) + "$</p>" +
                                          "<div class='buttonsTour'>" +
                                          "<a href = '/Home/Edit?id=" + tour.Id + "' class='btn btn-primary'>Edit tour</a>" +
                                          "<button class='btn btn-danger deleteTour'>Delete</button>" +
                                          "<a href = '/Home/ReadMore?id=" + tour.Id + "' > READ MORE... </a>" +
                                          "<span class='idTour' style='display: none;'>" + tour.Id + "</span>" +
                                          "</div>" +
                                          "</div>" +
                                          "</div>" +
                                          "</div>";
                            }
                        }
                    }
                    else
                    {
                        result += "" +
                                  "<div class='col-sm-12'>" +
                                  "<div>" +
                                  "<h4>Tours are not in this country!</h4>" +
                                  "</div>" +
                                  "</div>";
                    }
                }
                catch (ArgumentException ex)
                {
                    result = "Error" + ex.ToString();
                }
                catch (NullReferenceException ex)
                {
                    result = "Error" + ex.ToString();
                }
            }

            return(new HtmlString(result));
        }
Exemplo n.º 26
0
        private void InsertMultimediaDescription(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.MultimediaDescriptionsLocalType> multimediadescriptions)
        {
            if (Check(multimediadescriptions))
            {
                foreach (var item in multimediadescriptions[0].MultimediaDescription)
                {
                    var imageItems = item.ImageItems;

                    if (Check(imageItems))
                    {
                        using (var context = new TravelDBContext())
                        {
                            EfRepository <ImageItem> imageItemContext = new EfRepository <ImageItem> (context);

                            var imageItemCheck = (from i in imageItemContext.Table where i.HotelId == hotelId select i).ToList();
                            if (imageItemCheck.Count > 0)
                            {
                                imageItemContext.Delete(imageItemCheck);
                            }

                            foreach (var image in imageItems[0].ImageItem)
                            {
                                ImageItem imageItem = new ImageItem();

                                var url      = image.ImageFormat[0].URL;
                                var caption  = image.Description[0].Caption;
                                var category = image.Category;


                                var tap_extension = image.TPA_Extensions;
                                if (Check(tap_extension))
                                {
                                    var invokeCode = tap_extension[0].InvBlockCode;
                                    imageItem.InvBlockCode = Convert.ToInt32(invokeCode);
                                }
                                imageItem.Category       = Convert.ToInt32(category);
                                imageItem.URL            = url;
                                imageItem.Description    = caption;
                                imageItem.HotelId        = hotelId;
                                imageItem.LastMofifyTime = DateTime.Now;

                                imageItemContext.Insert(imageItem);

                                LoggerHelper(hotelCode, "Image:" + url + "," + caption + " Inserted");
                            }
                        }
                    }

                    var textitems = item.TextItems;

                    if (Check(textitems))
                    {
                        using (var context = new TravelDBContext())
                        {
                            EfRepository <TextItem> textItemContext = new EfRepository <TextItem>(context);
                            var itemCheck = (from i in textItemContext.Table where i.HotelId == hotelId select i).ToList();
                            if (itemCheck.Count > 0)
                            {
                                textItemContext.Delete(itemCheck);
                            }

                            foreach (var text in textitems[0].TextItem)
                            {
                                TextItem ti = new TextItem();
                                ti.HotelId = hotelId;

                                var category    = text.Category;
                                var Description = text.Description;
                                ti.Category        = Convert.ToInt32(category);
                                ti.DescriptionText = Description != null ? Description : text.URL;
                                ti.LastModityTime  = DateTime.Now;
                                LoggerHelper(hotelCode, "TextItem:" + category + "," + Description + " Inserted");
                                textItemContext.Insert(ti);

                                Console.WriteLine(category + "," + Description);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
        //增量获取不删除rateplan,直接更新此处
        public void InsertRate(int ratePlanId, IList <OTA_HotelRatePlanRS.RatePlansLocalType.RatePlanLocalType.RatesLocalType> rates, bool ifNeedCheck = false)
        {
            if (Check(rates))
            {
                foreach (var item in rates[0].Rate)
                {
                    using (var context = new TravelDBContext())
                    {
                        int RateInserted = -1;
                        EfRepository <Rate>           rateContext        = new EfRepository <Rate>(context);
                        EfRepository <BaseByGuestAmt> baseByGuestContext = new EfRepository <BaseByGuestAmt>(context);
                        DateTime startDate = Convert.ToDateTime(item.Start);
                        DateTime endDate   = Convert.ToDateTime(item.End);

                        if (ifNeedCheck)
                        {
                            var checkDataExists = (from r in rateContext.Table where r.RatePlanId == ratePlanId && r.Start.Value >= startDate && r.End.Value <= endDate select r).ToList();

                            if (checkDataExists.Count > 0)
                            {
                                LoggerHelper(ratePlanId.ToString(), "Rate" + startDate + "," + endDate + " Deleted");
                                rateContext.Delete(checkDataExists);
                            }
                        }

                        Rate rate = new Rate();
                        rate.RatePlanId       = ratePlanId;
                        rate.Start            = startDate;
                        rate.End              = endDate;
                        rate.IsInstantConfirm = Convert.ToBoolean(item.IsInstantConfirm);
                        rate.Status           = item.Status;
                        rate.NumberOfUnits    = Convert.ToInt32(item.NumberOfUnits);

                        var mealIncluded = item.MealsIncluded;
                        if (Check(mealIncluded))
                        {
                            rate.IsBreakfast     = Convert.ToBoolean(mealIncluded[0].Breakfast);
                            rate.BreakfastNumber = Convert.ToInt32(mealIncluded[0].NumberOfBreakfast);
                        }
                        rate.LastModifyTime = DateTime.Now;

                        rateContext.Insert(rate);

                        LoggerHelper(ratePlanId.ToString(), "RAte" + rate.Start + "," + rate.End + "Inserted");

                        RateInserted = rate.Id;

                        var BaseByGuestAmts = item.BaseByGuestAmts;
                        if (Check(BaseByGuestAmts))
                        {
                            var            BaseByGuestAmtItem = BaseByGuestAmts[0].BaseByGuestAmt[0];
                            BaseByGuestAmt bga = new BaseByGuestAmt();
                            bga.AmountBeforeTax = Convert.ToDecimal(BaseByGuestAmtItem.AmountBeforeTax);
                            bga.CurrencyCode    = BaseByGuestAmtItem.CurrencyCode;
                            bga.NumberOfGuests  = Convert.ToInt32(BaseByGuestAmtItem.NumberOfGuests);

                            bga.RateId    = RateInserted;
                            bga.ListPrice = Convert.ToDecimal(BaseByGuestAmtItem.ListPrice);


                            var tap_extension = BaseByGuestAmtItem.TPA_Extensions;
                            if (Check(tap_extension))
                            {
                                var otherCurrency     = tap_extension[0].OtherCurrency[0];
                                var AmountPercentType = otherCurrency.AmountPercentType[0];

                                var Amount = AmountPercentType.Amount;

                                var CurrencyCode = AmountPercentType.CurrencyCode;

                                bga.OtherCurrency     = Convert.ToDecimal(Amount);
                                bga.OtherCurrencyCode = CurrencyCode;
                            }
                            bga.LastModifyTime = DateTime.Now;
                            baseByGuestContext.Insert(bga);
                            LoggerHelper(ratePlanId.ToString(), "BaseByGuestAmts" + bga.AmountBeforeTax + "," + bga.CurrencyCode + "Inserted");
                        }



                        var Fees = item.Fees;
                        if (Check(Fees))
                        {
                            EfRepository <Fee> feeContext = new EfRepository <Fee>(context);
                            foreach (var fee in Fees[0].Fee)
                            {
                                Fee f = new Fee();
                                f.Code           = Convert.ToInt32(fee.Code);
                                f.Amount         = Convert.ToDecimal(fee.Amount);
                                f.CurrencyCode   = fee.CurrencyCode;
                                f.ChargeUnit     = Convert.ToInt32(fee.ChargeUnit);
                                f.RateId         = RateInserted;
                                f.LastModifyTime = DateTime.Now;
                                f.RateId         = RateInserted;
                                var Description = fee.Description;
                                if (Check(Description))
                                {
                                    f.DescriptionText = Description[0].Text;
                                }
                                f.LastModifyTime = DateTime.Now;
                                var feeExtension = fee.TPA_Extensions;
                                if (Check(feeExtension))
                                {
                                    var otherCurrency     = feeExtension[0].OtherCurrency[0];
                                    var AmountPercentType = otherCurrency.AmountPercentType[0];

                                    var feeAmount = AmountPercentType.Amount;
                                    var Currency  = AmountPercentType.CurrencyCode;

                                    LoggerHelper(ratePlanId.ToString(), "Fee Other Currency :" + Currency + "," + feeAmount);
                                }

                                feeContext.Insert(f);

                                LoggerHelper(ratePlanId, "Fee Other Currency Finished");
                            }
                        }



                        var GuaranteePolicies = item.GuaranteePolicies;
                        if (Check(GuaranteePolicies))
                        {
                            EfRepository <GuaranteePolicy> guaranteePolicyContext = new EfRepository <GuaranteePolicy>(context);
                            GuaranteePolicy gp = new GuaranteePolicy();
                            gp.RateId        = RateInserted;
                            gp.GuaranteeCode = Convert.ToInt32(GuaranteePolicies[0].GuaranteePolicy[0].GuaranteeCode);
                            var Holdtime = GuaranteePolicies[0].GuaranteePolicy[0].HoldTime;
                            if (!string.IsNullOrEmpty(Holdtime))
                            {
                                gp.HoldTime = Convert.ToDateTime(Holdtime);
                            }

                            gp.LastModifyTime = DateTime.Now;
                            guaranteePolicyContext.Insert(gp);
                        }

                        var CancelPolicies = item.CancelPolicies;
                        if (Check(CancelPolicies))
                        {
                            EfRepository <CancelPenalty> cancleContext = new EfRepository <CancelPenalty>(context);
                            CancelPenalty cp           = new CancelPenalty();
                            var           CancelPolicy = CancelPolicies[0].CancelPenalty[0];
                            cp.Start  = Convert.ToDateTime(CancelPolicy.Start);
                            cp.End    = Convert.ToDateTime(CancelPolicy.End);
                            cp.RateId = RateInserted;
                            var AmountPercent = CancelPolicy.AmountPercent[0];
                            cp.AmountPercent = Convert.ToDecimal(AmountPercent.Amount);
                            cp.CurrencyCode  = AmountPercent.CurrencyCode;

                            var CancleExtension = CancelPolicy.TPA_Extensions;
                            if (Check(CancleExtension))
                            {
                                var otherCurrency     = CancleExtension[0].OtherCurrency[0];
                                var AmountPercentType = otherCurrency.AmountPercentType[0];

                                cp.OtherCurrencyAmount = Convert.ToDecimal(AmountPercentType.Amount);
                                cp.OtherCurrencyCode   = AmountPercentType.CurrencyCode;

                                cancleContext.Insert(cp);

                                LoggerHelper(ratePlanId, "Cancle Pennalty  " + cp.OtherCurrencyAmount + "Inserted");
                            }
                        }

                        var rateExtension = item.TPA_Extensions;
                        if (Check(rateExtension))
                        {
                            var RebatePromotion = rateExtension[0].RebatePromotion;
                            if (Check(RebatePromotion))
                            {
                                EfRepository <RateExtension> rateExtensionContext = new EfRepository <RateExtension>(context);

                                RateExtension re = new RateExtension();
                                foreach (var rebate in RebatePromotion)
                                {
                                    re.StartPeriod  = Convert.ToDateTime(rebate.StartPeriod);
                                    re.EndPeriod    = Convert.ToDateTime(rebate.EndPeriod);
                                    re.ProgramName  = rebate.ProgramName;
                                    re.Amount       = Convert.ToDecimal(rebate.Amount);
                                    re.CurrencyCode = rebate.CurrencyCode;
                                    re.Code         = Convert.ToInt32(rebate.Code);
                                    re.RateId       = RateInserted;
                                    if (Check(rebate.Description))
                                    {
                                        var des = rebate.Description[0].Text;
                                        re.DescriptionText = des;

                                        Console.WriteLine(des);
                                    }
                                }
                                re.LastModifyTime = DateTime.Now;
                                rateExtensionContext.Insert(re);
                            }

                            var PayChange = rateExtension[0].PayChange;



                            Console.WriteLine(PayChange);
                        }
                    }
                }
            }
        }