public JsonResult SaveRoomAvailabilityAndRate(string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType, string WeekDay, string DateIDArray,string WeekDayIDArray,string SinglePriceNameArray,string DoublePriceNameArray,string RoomPriceNameArray, string AvailableRoomCountNameArray, string MinimumStayNameArray, string CloseToArrivalArray, string CloseToDepartureArray, string ClosedArray) { int i = 1; int RoomID = Convert.ToInt32(RoomType); BizContext = (BizContext)Session["GBAdminBizContext"]; int Hotelid = BizContext.HotelID; long UserSessionID= Convert.ToInt64(BizContext.UserSessionID); Session["GBAdminBizContext"] = BizContext; RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository(); try { var HotelRooms = ObjRep.GetHotelRooms(Hotelid).FirstOrDefault(f => f.RoomID == RoomID); int MaximamPeopleCount = GetMaximamPeopleCount(HotelRooms); ObjRep.CreateHotelRoomAvailability(RoomType, StartDate, Enddate, HotelRooms); ObjRep.CreateHotelRoomRate(RoomType, StartDate, Enddate, AccommodationType, PricePolicy); ObjRep.SaveRoomAvailabilityAndRate(Convert.ToInt32(AccommodationType), Convert.ToInt32(PricePolicy), Convert.ToInt32(RoomType), MaximamPeopleCount, DateIDArray, SinglePriceNameArray, DoublePriceNameArray, RoomPriceNameArray, AvailableRoomCountNameArray, MinimumStayNameArray, CloseToArrivalArray, CloseToDepartureArray, ClosedArray,UserSessionID, this); } catch (Exception ex) { string hostName1 = Dns.GetHostName(); string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString(); string PageName = Convert.ToString(Session["PageName"]); //string GetUserIPAddress = GetUserIPAddress1(); using (BaseRepository baseRepo = new BaseRepository()) { //BizContext BizContext1 = new BizContext(); BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress); } Session["PageName"] = ""; string error = ErrorHandling.HandleException(ex); return this.Json(new DataSourceResult { Errors = error }); } return Json(i, JsonRequestBehavior.AllowGet); }
public JsonResult LoadHotelRate(string Mode, string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType) { int i = 1; int j = 1; RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository(); List<RoomRateExt> RoomDetailList = new List<RoomRateExt>(); try { AssignBizContext(); int HotelID = BizContext.HotelID; HotelRooms = modelHotelRateAndAvailability.GetHotelRooms("RoomTypeName", HotelID); foreach (DataRow hotelRoom in HotelRooms.Rows) { ObjRep.CreateHotelRoomRate(hotelRoom["ID"].ToString(), StartDate, Enddate, AccommodationType, PricePolicy); int RoomID = Convert.ToInt32(hotelRoom["ID"]); var HotelRoomsNew = ObjRep.GetHotelRooms(HotelID).FirstOrDefault(f => f.RoomID == RoomID); ObjRep.CreateHotelRoomAvailability(hotelRoom["ID"].ToString(), StartDate, Enddate, HotelRoomsNew); } if (Mode == "1") { Dates = modelRepo.GetDates("Date", StartDate, Enddate); HotelRate = modelRepo.GetHotelRate(HotelID, StartDate, Enddate, AccommodationType, PricePolicy); var count = HotelRate.Rows.Count; foreach (DataRow Date in Dates.Rows) { foreach (DataRow Room in HotelRooms.Rows) { RoomRateExt Obj = new RoomRateExt(); Obj.DateID = Convert.ToInt32(Date["ID"]); Obj.Date = Convert.ToDateTime(Date["Date"]); Obj.DayID = Convert.ToInt32(Date["DayID"]); Obj.Day = Convert.ToInt32(Date["Day"]); Obj.WeekDay = Convert.ToInt32(Date["WeekDay"]); Obj.DayName = Convert.ToString(Date["DayName"]); Obj.MonthID = Convert.ToInt32(Date["MonthID"]); Obj.MonthName = Convert.ToString(Date["MonthName"]); Obj.Year = Convert.ToInt32(Date["Year"]); string hotelRoomID = Room["ID"].ToString(); string dateID = Date["ID"].ToString(); if (j <= count) { DataRow hotelRoomRate = HotelRate.Select("HotelRoomID=" + hotelRoomID + " AND DateID=" + dateID)[0]; Obj.RoomTypeID = Convert.ToInt32(Room["RoomTypeID"]); Obj.RoomTypeName = Convert.ToString(Room["RoomTypeName"]); Obj.HotelRoomID = Convert.ToInt32(Room["ID"]); Obj.MaxPeopleCount = Convert.ToInt32(Room["MaxPeopleCount"]); if (hotelRoomID == RoomType || RoomType == string.Empty) { Obj.txtSinglePrice = true; } else { Obj.txtSinglePrice = false; } if (Obj.txtSinglePrice == true) { Obj.txtDoublePrice = true; } else { Obj.txtDoublePrice = false; } if (Obj.txtSinglePrice == true) { Obj.txtRoomPrice = true; } else { Obj.txtRoomPrice = false; } //Obj.txtSinglePrice = true; //Obj.txtDoublePrice = true; //Obj.txtRoomPrice = true; Obj.SinglePrice = FormatToNumber(hotelRoomRate["SinglePrice"], "en-Gb", "en", 2); Obj.DoublePrice = FormatToNumber(hotelRoomRate["DoublePrice"], "en-Gb", "en", 2); Obj.RoomPrice = FormatToNumber(hotelRoomRate["RoomPrice"], "en-Gb", "en", 2); if (Convert.ToBoolean(hotelRoomRate["Closed"])) { Obj.hotelRoomAvailabilityText = "Closed"; Obj.txtSinglePrice = false; Obj.txtDoublePrice = false; Obj.txtRoomPrice = false; } else if (Convert.ToInt16(hotelRoomRate["AvailableRoomCount"]) == 0) { Obj.hotelRoomAvailabilityText = "Full"; } else if (Convert.ToBoolean(hotelRoomRate["RoomRateMissing"])) { Obj.hotelRoomAvailabilityText = "RateMissing"; } else { Obj.hotelRoomAvailabilityText = "Available"; } } RoomDetailList.Add(Obj); } j = j + 1; } } else if (Mode == "2") { foreach (DataRow Room in HotelRooms.Rows) { RoomRateExt Obj = new RoomRateExt(); string HotelRoomID = Room["ID"].ToString(); Obj.RoomTypeName = Convert.ToString(Room["RoomTypeName"]); Obj.HotelRoomID = Convert.ToInt32(Room["ID"]); Obj.MaxPeopleCount = Convert.ToInt32(Room["MaxPeopleCount"]); if (HotelRoomID == RoomType || RoomType == string.Empty) { Obj.txtSinglePrice = true; } if (Obj.txtSinglePrice == true && Obj.MaxPeopleCount > 1) { Obj.txtDoublePrice = true; } if (Obj.txtSinglePrice == true && Obj.MaxPeopleCount > 2) { Obj.txtRoomPrice = true; } RoomDetailList.Add(Obj); } } } catch (Exception ex) { string hostName1 = Dns.GetHostName(); string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString(); string PageName = Convert.ToString(Session["PageName"]); //string GetUserIPAddress = GetUserIPAddress1(); using (BaseRepository baseRepo = new BaseRepository()) { //BizContext BizContext1 = new BizContext(); BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress); } Session["PageName"] = ""; string error = ErrorHandling.HandleException(ex); return this.Json(new DataSourceResult { Errors = error }); } return Json(RoomDetailList, JsonRequestBehavior.AllowGet); }
//public JsonResult LoadHotelAvailabilityAndRate(string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType, string WeekDay) //{ // int i = 1; // int RoomID = Convert.ToInt32(RoomType); // BizContext = (BizContext)Session["GBAdminBizContext"]; // int Hotelid = BizContext.HotelID; // Session["GBAdminBizContext"] = BizContext; // RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository(); // var HotelRooms = ObjRep.GetHotelRooms(Hotelid).FirstOrDefault(f => f.RoomID == RoomID); // int MaximamPeopleCount = GetMaximamPeopleCount(HotelRooms); // ObjRep.CreateHotelRoomAvailability(RoomType, StartDate, Enddate, HotelRooms); // ObjRep.CreateHotelRoomRate(RoomType, StartDate, Enddate, AccommodationType, PricePolicy); // // ObjRep.Getdates(StartDate, Enddate, WeekDay); // //ObjRep.GetHotelAvailability(Hotelid,StartDate, Enddate); // //ObjRep.GetHotelRate(Hotelid, StartDate, Enddate, AccommodationType, PricePolicy); // return Json(ObjRep.Getdates(StartDate, Enddate, WeekDay), JsonRequestBehavior.AllowGet); //} //public string ConvertToDateTime(string strDateTime) //{ // DateTime dtFinaldate; // string sDateTime; // dtFinaldate = Convert.ToDateTime(strDateTime); // string[] sDate = strDateTime.Split('.'); // sDateTime = sDate[1] + '/' + sDate[0] + '/' + sDate[2]; // return sDateTime; //} public JsonResult LoadHotelAvailabilityAndRate(string StartDate, string Enddate, string RoomType, string PricePolicy, string AccommodationType, string WeekDay) { //if(CultureCode =="de-DE" || CultureCode=="ru-RU") //{ // DateTime dt = Convert.ToDateTime(StartDate); // DateTime dt1 = Convert.ToDateTime(Enddate); // string strDate = ConvertToDateTime(StartDate); // StartDate = strDate; // string Enddat = ConvertToDateTime(Enddate); // Enddate = Enddat; //} int RoomID = 0; try { RoomID = Convert.ToInt32(RoomType); } catch { RoomID = 0; } BizContext = (BizContext)Session["GBAdminBizContext"]; int Hotelid= BizContext.HotelID; Session["GBAdminBizContext"] = BizContext; RoomAvailabilityAndRateRepository ObjRep = new RoomAvailabilityAndRateRepository(); var HotelRooms = ObjRep.GetHotelRooms(Hotelid).FirstOrDefault(f => f.RoomID == RoomID); int MaximamPeopleCount = GetMaximamPeopleCount(HotelRooms); ObjRep.CreateHotelRoomAvailability(RoomType, StartDate, Enddate, HotelRooms); ObjRep.CreateHotelRoomRate(RoomType, StartDate, Enddate, AccommodationType, PricePolicy); DataTable AvailabilityTable = ObjRep.GetHotelAvailability(Hotelid, StartDate, Enddate); DataTable RateTable = ObjRep.GetHotelRate(Hotelid, StartDate, Enddate, AccommodationType, PricePolicy); return Json(ObjRep.Getdates(StartDate, Enddate, WeekDay, AvailabilityTable, RateTable, Convert.ToInt32(RoomType), MaximamPeopleCount), JsonRequestBehavior.AllowGet); }