public JsonResult BindRatePlans(string id) { int cid = int.Parse(id); List <PNames> results = BL_tblPropertyRatePlanMap.GetRatePlanRoomWise(Convert.ToInt32(id), Convert.ToInt32(Session["PropId"].ToString())); return(Json(new { suggestions = results }, JsonRequestBehavior.AllowGet)); }
public int AddRatePlan(etblPropertyRatePlanMap prop) { try { if (ModelState.IsValid) { prop.iPropId = Convert.ToInt32(Session["PropId"].ToString()); prop.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)(Session["UserDetails"])).iUserId; prop.dtActionDate = DateTime.Now; prop.bIsPlus = Convert.ToBoolean(prop.iIsPlus); prop.bIsPercent = Convert.ToBoolean(prop.iIsPercent); prop.bIsBefore = Convert.ToBoolean(prop.iIsBefore); prop.bIsSecretDeal = Convert.ToBoolean(prop.bIsSecretDeal); JArray jsonResponse = JArray.Parse(prop.CancellationPolicyJSonData.Replace("\\", "\"")); List <CancellationPolicyGrid> jArray = (List <CancellationPolicyGrid>)JsonConvert.DeserializeObject <List <CancellationPolicyGrid> >(jsonResponse.ToString()); // prop.iLinkRatePlanId = prop.iRPId; prop.cStatus = "A"; //get all Cancellation Policies comma seperated if (prop.SelectedRoomType != null) { prop.sRoomTypeId = prop.SelectedRoomType.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + ", " + s2); } //get all Cancellation Policies comma seperated if (prop.SelectedAmenityID != null) { prop.sAmenityId = prop.SelectedAmenityID.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + ", " + s2); } //get all Cancellation Policies comma seperated //if (prop.SelectedCancellationPolicy != null) //{ // prop.sCancellationPolicy = prop.SelectedCancellationPolicy.Select(i => i.ToString(CultureInfo.InvariantCulture)).Aggregate((s1, s2) => s1 + ", " + s2); //} if (prop.bLinkToExistingRatePlan == false) { prop.iLinkRatePlanId = null; prop.bIsPlus = null; prop.bIsPercent = null; prop.dValue = null; } int result = BL_tblPropertyRatePlanMap.AddRecord(prop, jArray); return(result); } else { return(-1); } } catch (Exception) { throw; } }
public JsonResult BindRoomType(int Id, string type) { int PropId = Convert.ToInt32(Session["PropId"].ToString()); List <CheckBoxList> results = new List <CheckBoxList>(); if (Session["Mode"] != null) { if (Session["Mode"].ToString() == "Add") { if (type == "ShowBase" || type == "First") { results = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(Id, PropId, null, false); } else { if (Id != 0) { results = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(Id, PropId, Id, false); } else { results = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(PropId, 0); } } } if (Session["Mode"].ToString() == "Copy" || Session["Mode"].ToString() == "Modify") { if (type == "First") { etblPropertyRatePlanMap obj = new etblPropertyRatePlanMap(); obj = BL_tblPropertyRatePlanMap.GetAllRatePlansByID(Convert.ToInt32(Session["RecId"].ToString())); results = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(Convert.ToInt32(Session["RecId"].ToString()), PropId, obj.iLinkRatePlanId, true); } else if (type == "RPChange") { results = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(Id, PropId, Id, false); } else if (type == "ShowBase") { results = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(Convert.ToInt32(Session["RecId"].ToString()), PropId, null, false); } } } return(Json(new { suggestions = results }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetParentRatePlanValidity(int Id, string type) { int PropId = Convert.ToInt32(Session["PropId"].ToString()); List <string> results = new List <string>(); if (Id != 0) { results = BL_tblPropertyRatePlanMap.GetParentRatePlanValidity(Id, PropId); } return(Json(new { suggestions = results }, JsonRequestBehavior.AllowGet)); }
public JsonResult Autocomplete(string term) { var result = new List <KeyValuePair <string, string> >(); IList <RPNames> List = new List <RPNames>(BL_tblPropertyRatePlanMap.GetRatePlansForTypehead(term)); foreach (var item in List) { result.Add(new KeyValuePair <string, string>(item.Id.ToString(), item.Name)); } var result3 = result.Where(s => s.Value.ToLower().Contains(term.ToLower())).Select(w => w).ToList(); //var result3 = result.ToList(); return(Json(result3, JsonRequestBehavior.AllowGet)); }
public JsonResult GetUpgradeRooms(string Room, string rateplan) { if (rateplan == "") { rateplan = "0"; } if (Room == "") { Room = "0"; } List <PropertyRooms> results = BL_tblPropertyRatePlanMap.GetUpgradeRooms(Convert.ToInt32(Room), Convert.ToInt32(rateplan), Convert.ToInt32(Session["PropId"])); return(Json(new { suggestions = results }, JsonRequestBehavior.AllowGet)); }
public JsonResult BindCancellationPolicy() { List <CheckBoxList> results = new List <CheckBoxList>(); int PropId = Convert.ToInt32(Session["PropId"].ToString()); if (PropId != 0) { results = BL_tblPropertyRatePlanMap.GetCancellationPolicy(PropId); } else { results = null; } return(Json(new { suggestions = results }, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(int Id) { string strReturn = string.Empty; try { etblPropertyRatePlanMap prop = new etblPropertyRatePlanMap(); prop = BL_tblPropertyRatePlanMap.GetAllRatePlansByID(Id); if (prop.cStatus == "A") { prop.cStatus = "I"; } else if (prop.cStatus == "I") { prop.cStatus = "A"; } int val = BL_tblPropertyRatePlanMap.DeleteRecord(prop); if (val == 1) { if (prop.cStatus == "I") { TempData["msg"] = "Disabled successfully "; } else { TempData["msg"] = "Enabled successfully"; } } else { TempData["msg"] = "Kindly try after some time"; } } catch (Exception) { } return(RedirectToAction("Index")); }
public ActionResult Copy(int Id) { int PropId = Convert.ToInt32(Session["PropId"].ToString()); etblPropertyRatePlanMap obj = new etblPropertyRatePlanMap(); obj = BL_tblPropertyRatePlanMap.GetAllRatePlansByID(Id); obj.Mode = "Copy"; Session["Mode"] = "Copy"; Session["RecId"] = Id; obj.heading = "Add Rate Plan"; obj.RoomTypeItems = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(Id, PropId, obj.iLinkRatePlanId, true); obj.Amenties = BL_tblPropertyRatePlanMap.GetAmentiesCheckBox(obj.sAmenityId); //obj.CancellationPolicy = BL_tblPropertyRatePlanMap.GetCancellationPolicy(PropId); obj.CancellationPolicy = BL_tblPropertyRatePlanMap.GetCancellationPolicy(PropId, obj.sCancellationPolicy); obj.iCancellationChkBox = obj.CancellationPolicy.Count(); obj.iUpdateRPId = Id; var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(obj.CancellationPolicyGrid); ViewData["cancellationJSON"] = json; return(PartialView("pvRatePlan", obj)); }
public ActionResult Add() { int PropId = Convert.ToInt32(Session["PropId"].ToString()); TempData["PropID"] = Convert.ToInt32(Session["PropId"].ToString()); etblPropertyRatePlanMap obj = new etblPropertyRatePlanMap(); obj.RoomTypeItems = BL_tblPropertyRatePlanMap.GetRoomTypeCheckBox(PropId, 0); obj.Amenties = BL_tblPropertyRatePlanMap.GetAmentiesCheckBox(); obj.CancellationPolicy = BL_tblPropertyRatePlanMap.GetCancellationPolicy(PropId); obj.iCancellationChkBox = obj.CancellationPolicy.Count(); obj.iMinLengthStay = 1; obj.Mode = "Add"; Session["Mode"] = "Add"; obj.heading = "Add Rate Plan"; obj.iPropId = PropId; var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(obj.CancellationPolicyGrid); ViewData["cancellationJSON"] = json; return(PartialView("pvRatePlan", obj)); }
public ActionResult AddUpdate(etblPropertyTaxMap eObj) { object result = null; try { if (ModelState.IsValid) { if (eObj.iRoomId == 0) { eObj.iRoomId = null; } if (eObj.SelectedTaxes != null) { JArray jArray = (JArray)JsonConvert.DeserializeObject(eObj.SelectedTaxes.Replace("\\", "\"")); if (jArray != null) { List <etblPropertyTaxesMap> lstPropertyTaxesMap = new List <etblPropertyTaxesMap>(); foreach (var item in jArray) { lstPropertyTaxesMap.Add(new etblPropertyTaxesMap() { iTaxId = Convert.ToInt32(item["TaxId"]), bIsPercent = Convert.ToBoolean(item["Type"]), dValue = Convert.ToDecimal(item["value"]), dtActionDate = DateTime.Now, iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId }); } eObj.PropertyTaxesList = lstPropertyTaxesMap; } } //if (eObj.Mode == "Edit") //{ // bool ResultType = BL_tblPropertyTaxMap.CheckRecordExist(eObj.iPropId, eObj.iRoomId,eObj.iPropTaxId); // //var existingRecord = BL_tblPropertyTaxMap.GetSingleRecordById(eObj.iPropTaxId); // //if(string.IsNullOrEmpty(eObj.PlanId)) // //{ // // if (existingRecord.iRoomId != null) // // { // // var ratePlanResult = new { st = 0, msg = "Tax already added / mapped with another ratePlan ." }; // // return Json(ratePlanResult, JsonRequestBehavior.AllowGet); // // } // //} // //else // //{ // if (ResultType == true) // { // //var ratePlanResult = new { st = 0, msg = "Tax already added / mapped with another ratePlan ." }; // var ratePlanResult = new { st = 0, msg = "Tax already added." }; // return Json(ratePlanResult, JsonRequestBehavior.AllowGet); // } // //} //} eObj.dtStayFrom = clsUtils.ConvertddmmyyyytoDateTime(eObj.stayfrom); eObj.dtStayTo = clsUtils.ConvertddmmyyyytoDateTime(eObj.stayto); int i = BL_tblPropertyTaxMap.CheckStatus(Convert.ToInt32(eObj.iPropId), Convert.ToInt32(eObj.iRPId), Convert.ToInt32(eObj.iRoomId), Convert.ToDateTime(eObj.dtStayFrom), Convert.ToDateTime(eObj.dtStayTo), Convert.ToInt32(eObj.iPropTaxId)); if (i > 0) { result = new { st = 0, msg = "Taxes for these dates has already been made." }; return(Json(result, JsonRequestBehavior.AllowGet)); } if (eObj.Mode == "ADD") { eObj.iPropId = Convert.ToInt32(Session["PropId"]); eObj.dtActionDate = DateTime.Now; eObj.cStatus = "A"; eObj.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId; int j = BL_tblPropertyTaxMap.AddRecord(eObj); if (j == 1) { bool bookingAffected = false; var statusChange = BL_tblPropertyTaxMap.CheckAffectedBookingsAfterPropertyTaxChange(Convert.ToDateTime(eObj.dtStayFrom), Convert.ToDateTime(eObj.dtStayTo)); if (statusChange.Key == 1) { bookingAffected = true; } result = new { st = 1, bookingAffected = bookingAffected, msg = "Added successfully." }; } else if (j == 2) { result = new { st = 0, msg = "Tax already exists for selected Rate Plan and Stay Validity" }; } else if (j == 3) { result = new { st = 0, msg = "Tax already exists for single room types" }; } else if (j == 4) { result = new { st = 0, msg = "Tax already exists for all rooms" }; } else { result = new { st = 0, msg = "Kindly try after some time" }; } } else if (eObj.Mode == "Edit") { eObj.iActionBy = ((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId; eObj.dtActionDate = DateTime.Now; int j = BL_tblPropertyTaxMap.UpdateRecord(eObj); if (j == 1) { bool bookingAffected = false; var statusChange = BL_tblPropertyTaxMap.CheckAffectedBookingsAfterPropertyTaxChange(Convert.ToDateTime(eObj.dtStayFrom), Convert.ToDateTime(eObj.dtStayTo)); if (statusChange.Key == 1) { bookingAffected = true; } result = new { st = 1, bookingAffected = bookingAffected, msg = "Updated successfully." }; } else if (j == 2) { result = new { st = 0, msg = "Tax already exixts for selected Rate Plan and Stay Validity" }; } else { result = new { st = 0, msg = "Kindly try after some time" }; } } } else { string errormsg = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { errormsg += error.ErrorMessage; errormsg += "</br>"; } } result = new { st = 0, msg = errormsg }; } eObj.ListRatePlans = BL_tblPropertyRatePlanMap.GetAllRatePlans(Convert.ToInt32(Session["PropId"])); eObj.ListTaxes = BL_Tax.GetAllTaxOfProperty(eObj.iPropTaxId); } catch (Exception) { result = new { st = 0, msg = "Kindly try after some time" }; } // return PartialView("PropertyTax", eObj); return(Json(result, JsonRequestBehavior.AllowGet)); }