public ActionResult Create(RoomTypeVM model) { try { string roomTypeId = string.Empty; model.CreatedBy = LogInManager.LoggedInUserId; #region Check Room Type Code Available. if (this.CheckRoomTypeCodeAvailable(model.Id, model.RoomTypeCode) == false) { return(Json(new { IsSuccess = false, errorMessage = string.Format("Room Type Code : {0} already exist.", model.RoomTypeCode) }, JsonRequestBehavior.AllowGet)); } #endregion roomTypeId = roomTypeRepository.AddRoomType(model); if (!string.IsNullOrWhiteSpace(roomTypeId)) { #region Add Rate (Default 100) for each Rate Type. var rateTypes = rateTypeRepository.GetRateType(string.Empty); if (rateTypes != null && rateTypes.Count > 0) { foreach (var rateType in rateTypes) { RoomTypeRateTypeMappingVM roomTypeRateTypeMapping = new RoomTypeRateTypeMappingVM(); roomTypeRateTypeMapping.RoomTypeId = Guid.Parse(roomTypeId); roomTypeRateTypeMapping.RateTypeId = rateType.Id; roomTypeRateTypeMapping.Amount = 100; //Default Price. roomTypeRateTypeMapping.IsActive = true; roomTypeRateTypeMapping.CreatedBy = LogInManager.LoggedInUserId; rateRepository.AddRoomTypeRateTypeMapping(roomTypeRateTypeMapping); } } #endregion return(Json(new { IsSuccess = true, data = new { RoomTypeId = model.Id } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Room Type details not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Create"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }
public ActionResult Create(RoomTypeRateTypeMappingVM model) { try { string source = string.Empty; string url = string.Empty; string qid = string.Empty; string mappingId = string.Empty; model.IsWeekEndPrice = false; #region Check Source Parameters if (Request.Form["Source"] != null && !string.IsNullOrWhiteSpace(Convert.ToString(Request.Form["Source"]))) { source = Convert.ToString(Request.Form["Source"]); if (source == "WeekDayPrice") { TempData["TabName"] = "WeekDayPrice"; url = Url.Action("ManagePrice", "Rate"); model.IsWeekEndPrice = false; } else if (source == "WeekEndPrice") { TempData["TabName"] = "WeekEndPrice"; url = Url.Action("ManagePrice", "Rate"); model.IsWeekEndPrice = true; } } #endregion model.CreatedBy = LogInManager.LoggedInUserId; #region Check Room Type Rate Type Mapping Available. if (this.CheckRoomTypeRateTypeMappingAvailable(model.Id, model.RoomTypeId, model.RateTypeId, model.IsWeekEndPrice) == false) { return(Json(new { IsSuccess = false, errorMessage = string.Format("Selected mapping already exist.") }, JsonRequestBehavior.AllowGet)); } #endregion mappingId = rateRepository.AddRoomTypeRateTypeMapping(model); #region Check External URL if (!string.IsNullOrWhiteSpace(url)) { return(Json(new { IsSuccess = true, IsExternalUrl = true, data = url }, JsonRequestBehavior.AllowGet)); } #endregion if (!string.IsNullOrWhiteSpace(mappingId)) { return(Json(new { IsSuccess = true, data = new { MappingId = model.Id } }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, errorMessage = "Rate details not saved successfully." }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { Utility.Utility.LogError(e, "Create"); return(Json(new { IsSuccess = false, errorMessage = e.Message })); } }